Difficulties in QCOMBOBOX
-
I am actually selecting a name of a doctor from a list of doctor names and according to the predefined data given by each doctor, certain fix values are displayed in the LCDnumber, the values for temperature and humidity are just for displaying purpose on the GUI.
For example: There are 3 doctors namely Dr. ABC, Dr. PQR, Dr. XYZ, which are a part of list of combobox, now each doctor requires certain fix values of temperature and humidity on the GUI to be displayed as they select there own name on the combobox. -
Hi,
Then use the parameter provided by
currentIndexChanged
(either the text or integer value) to retrieve the matching data from whatever source you may have. -
Which part ? The slot handling or the data handling ?
For the slot just add the correct parameter to it:
void MainWindow::temp1(int index) { }
Or if using the QString parameter:
void MainWindow::temp1(const QString &text) { }
Don't forget to update your connect statement to match.
If it's the data part that is problematic then you have to explain where it's located and how you access it.
-
There are two
currentIndexChanged
signals. The one you used that has an int parameter and the second one that has a QString parameter.Then depending on which one you need in order to do the stuff you want to do, you have to connect matching signals and slot. You have the choice between the two samples I wrote in my last post.
-
@SGaist okay so, I did this
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(temp1(int index)));
and
void MainWindow::temp1(int index)
{
ui->temp->display(23);
ui->humidity->display(40);
}but still there are no changes in the GUI as I select the name from combobox.
-
Don't pass the parameter name, just the type i.e.
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(temp1(int))); and
-
You^re welcome !
Since you have it working now, please mark the thread as solved using the "Tool Topic" button so that other forum users may know a solution has bben foud )