コンボボックスの値とラベルを接続して、コンボボックスが変更されたときにラベルがそれを反映するようにしようとしています。私は答えを見つけようと心をググってみましたが、今のところ、何も機能していません。それでもエラーが発生します:no matching function for call to mainWindow::connect(QComboBox*&, const char [38], QString*, const char [26])
QObject::connect
私はQtを扱った他のQWidget::connect
何かを試しましたが、役に立ちませんでした。
コンボボックスの値を示すラベルを作成することは、プログラムの最終的な意図ではありません。むしろ、単純なラベルで機能させてから、表示したいものに変更したいと思います(したがって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();
}
どんな助けでも大歓迎です!