PDA

View Full Version : program a combobox in a dialog



Devoraz
29th July 2009, 08:58
hi. i have a dialog created using QtDesginer. can i add a combobox in that dialog using pure c++ language? example show in the code below.



void SettingsWindow::drawCombobox()
{
QSettings settings;

endDeviceCombobox = new QComboBox(ui.groupBox_2);
endDeviceCombobox->setGeometry(QRect(190, 20, 111, 21));
endDeviceCombobox->setEditable(false);
endDeviceCombobox->setDuplicatesEnabled(false);
}

i tried but the combobox doesnt appear in the dialog. why so?

spirit
29th July 2009, 09:24
trye to call show method, i.e.


...
endDeviceCombobox->show();

wagmare
29th July 2009, 09:32
just design a empty QFrame in designer and add QComboBox to the widget in your code ..

numbat
29th July 2009, 10:42
Your code worked for me. One possibility is that your group box is too small.


MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QGroupBox * gb = new QGroupBox;
QComboBox * endDeviceCombobox = new QComboBox(gb);
endDeviceCombobox->setGeometry(QRect(190, 20, 111, 21));
endDeviceCombobox->setEditable(false);
endDeviceCombobox->setDuplicatesEnabled(false);

setCentralWidget(gb);
}