Results 1 to 4 of 4

Thread: QComboBox Issue

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Red face QComboBox Issue

    I am using Qt 4.3.0 and inside my QComboBox I have very long QStrings. However I want the QComboBox to be less wide than the QStrings. I have no difficulty in accomplishing this when I display my GUI. However what I want to be able to do is when I click on the QComboBox to drop down my possible selections, I would like for this box to grow to the width of its contents but then shrink back to normal size when I close the combo box. How is this possible? I have played around with the Size Policies and have not had any luck coming close to accomplishing what I want. Thanks!

  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: QComboBox Issue

    you can try to sub-class from QComboBox and reload
    Qt Code:
    1. void QComboBox::showPopup ()
    To copy to clipboard, switch view to plain text mode 

    very simple example
    Qt Code:
    1. MyComboBox::MyComboBox(QWidget *parent) : QComboBox(parent)
    2. {
    3. }
    4.  
    5. void MyComboBox::showPopup()
    6. {
    7. view()->setFixedSize(300, 300);
    8. QComboBox::showPopup();
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to spirit for this useful post:

    ToddAtWSU (21st August 2008)

  4. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox Issue

    I will give that a try. Thanks!

  5. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox Issue

    That worked!!! Thanks again!

Similar Threads

  1. QWizard, QComboBox and registerField() issue
    By RThaden in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2008, 12:18
  2. Replies: 0
    Last Post: 2nd April 2008, 07:48
  3. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 19:25
  4. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  5. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14

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.