我正在QPushButtons (image) 的aAxB電網和存儲他們的名字到QStringList中 像這樣從QStringList中
QString Enemy_name = "Enemy_n"+QString::number(counter);
counter++;
QPushButton *Enemy_ship =new QPushButton(ui->Enemy);
Enemy_ship->setObjectName(Enemy_name);
Enemy_ship->setGeometry(15*b,15*i,10,10);
Enemy_ship->setVisible(true);
Enemy_name += "G";
Enemy_names += Enemy_name;
}
}
Enemy_list = Enemy_names.split("G");
在列表中存儲的數據在這裏被使用 在那裏我得到一些錯誤的轉換這 的代碼是
void MainWindow::lastrow(){
int n=0;
QString firstinrow = Enemy_list[0]; //Getting QPushButton Objectname from the list
QPushButton *b = firstinrow; //Making pointer *b for the object name
QString temp; //Same but temporary
QPushButton *btemp; //...
do{
n++; //Counter for list position
temp = &Enemy_list[n]; //Getting object name from position n in the list
*btemp = temp; //temp button pointer
}while(!ui->*b->geometry.y() == ui->*btemp->geometry.y()); //checking Y of those 2 for not same Y
// QString lastinrow = &Enemy_list[n-1];
}
錯誤
E:\QT\Try\mainwindow.cpp:81: Chyba: cannot convert 'QString' to 'QPushButton*' in initialization
QPushButton *b = firstincol;
^
E:\QT\Try\mainwindow.cpp:86: Chyba: invalid conversion from 'QString*' to 'char' [-fpermissive]
temp = &Enemy_list[n];
^
E:\QT\Try\mainwindow.cpp:87: Chyba: no match for 'operator=' (operand types are 'QPushButton' and 'QString')
*btemp = temp;
^
E:\QT\Try\mainwindow.cpp:88: Chyba: 'b->QWidget::geometry' does not have class type
}while(!ui->*b->geometry.y() == ui->*btemp->geometry.y());
E:\QT\Try\mainwindow.cpp:88: Chyba: 'btemp->QWidget::geometry' does not have class type
}while(!ui->*b->geometry.y() == ui->*btemp->geometry.y());
^
^
我有一個字符串列表與對象名稱,我想從列表中取出對象名稱並閱讀它的幾何圖形,以確定它是否通過條件(在幾何中不同y) – bouchakx