我試圖連接一個組合框值和一個標籤,這樣當組合框更改標籤時反映了這一點。我一直在努力尋找答案,但是,至今爲止,沒有任何工作能夠奏效;我仍然得到的錯誤:no matching function for call to mainWindow::connect(QComboBox*&, const char [38], QString*, const char [26])
Qt沒有調用mainWindow :: connect()的匹配函數
我試過QObject::connect
,QWidget::connect
和其他任何與Qt處理,但無濟於事。
創建一個說明組合框值的標籤並不是我對程序的最終意圖。相反,我希望得到它與一個簡單的標籤工作,然後將其更改爲我想要它顯示(因此tempLabel
)。
mainwindow.h:
class MainWindow : public QMainWindow
{
public:
MainWindow();
private slots:
QString getClass(QComboBox *box);
};
mainwindow.cpp:
MainWindow::MainWindow()
{
QString qMathClassName;
QComboBox* mathClassCombo = new QComboBox;
QLabel* label = new QLabel(qMathClassName);
// omitting layout code...
connect(mathClassCombo, SIGNAL(currentIndexChanged(const QString &)),
&qMathClassName, SLOT(getClass(mathClassCombo)));
}
QString MainWindow::getClass(QComboBox *box)
{
return box->currentText();
}
任何幫助將不勝感激!
你混淆類,實例和值。這三件事不可互換。 QmathClassName是一個實例。它的類型是QString。它的值與「」類似。 – cgmb 2012-07-20 20:12:55