Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Regarding QmessageBox ok and cancel button after adding widgets
Forum Updated to NodeBB v4.3 + New Features

Regarding QmessageBox ok and cancel button after adding widgets

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Pradeep KumarP Offline
    Pradeep KumarP Offline
    Pradeep Kumar
    wrote on last edited by Pradeep Kumar
    #1

    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;
    label.setText("Label");
    
    QComboBox comboBox;
    comboBox.addItem("text 1");
    comboBox.addItem("text 2");
    
    QMessageBox msgbox;
    QLayout *l = msgbox.layout();
    msgbox.layout()->addWidget(&label);
    msgbox.layout()->addWidget(&comboBox);
    
    msgbox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    

    msgbox.exec();

    How can achieve ,
    Thanks,

    Pradeep Kumar
    Qt,QML Developer

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by alex_malyu
      #2

      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.

      1 Reply Last reply
      1
      • Pradeep KumarP Offline
        Pradeep KumarP Offline
        Pradeep Kumar
        wrote on last edited by
        #3

        Hi, @alex_malyu

        just did the same, inherited from QDialog.

        Thanks,

        Pradeep Kumar
        Qt,QML Developer

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved