Important: Please read the Qt Code of Conduct -

Regarding QmessageBox ok and cancel button after adding widgets

  • Hi,

    I am using QMessageBox , i want to add combobox and label, then display default messagebox button,
    but what is happenening is after displaying buttons, then the combobox and label are appearing.,

    QLabel label;
    QComboBox comboBox;
    comboBox.addItem("text 1");
    comboBox.addItem("text 2");
    QMessageBox msgbox;
    QLayout *l = msgbox.layout();
    msgbox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);


    How can achieve ,

  • QMessageBox is not designed to provide combobox.
    It is possible to hack it, but then you will have to check that your solution works on every version of Qt.
    Subclass QDialog and do there what you want.

  • Hi, @alex_malyu

    just did the same, inherited from QDialog.


Log in to reply