QComboBox::currentText()
-
my problem still non solved:
i start a program and change item manually (from 1 to 2), so in my opinion currentText() is "2" now, but QLabel always show me "abc1", why? i change it!
@
{
QApplication a(argc, argv);
QWidget w;
QComboBox* cmb = new QComboBox;
QLabel* lbl = new QLabel();
cmb->addItem("1");
cmb->addItem("2");
lbl->setText("abc"+cmb->currentText());
cmb->show();
lbl->show();return a.exec();
}
@ -
You have a fundamental problem with the setup of your application. You are showing "main.cpp". This part will be executed and the program will "wait" in a.exec() when you are able to change the items in the combobox. As mentioned by the others above you require the signal & slot logic for proper working. You should study some of the examples eg. "this one":http://qt-project.org/doc/qt-5.0/qtwidgets/dialogs-standarddialogs.html