Results 1 to 4 of 4

Thread: program a combobox in a dialog

  1. #1
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default program a combobox in a dialog

    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.

    Qt Code:
    1. void SettingsWindow::drawCombobox()
    2. {
    3. QSettings settings;
    4.  
    5. endDeviceCombobox = new QComboBox(ui.groupBox_2);
    6. endDeviceCombobox->setGeometry(QRect(190, 20, 111, 21));
    7. endDeviceCombobox->setEditable(false);
    8. endDeviceCombobox->setDuplicatesEnabled(false);
    9. }
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: program a combobox in a dialog

    trye to call show method, i.e.
    Qt Code:
    1. ...
    2. endDeviceCombobox->show();
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: program a combobox in a dialog

    just design a empty QFrame in designer and add QComboBox to the widget in your code ..
    "Behind every great fortune lies a crime" - Balzac

  4. #4
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: program a combobox in a dialog

    Your code worked for me. One possibility is that your group box is too small.
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. QGroupBox * gb = new QGroupBox;
    5. QComboBox * endDeviceCombobox = new QComboBox(gb);
    6. endDeviceCombobox->setGeometry(QRect(190, 20, 111, 21));
    7. endDeviceCombobox->setEditable(false);
    8. endDeviceCombobox->setDuplicatesEnabled(false);
    9.  
    10. setCentralWidget(gb);
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Program crashes on creating new dialog
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 11:52
  2. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  3. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Crash: using a dialog in a model
    By Brandybuck in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2006, 01:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.