View Full Version : QComboBox Issue

6th August 2008, 16:02
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!

6th August 2008, 18:24
you can try to sub-class from QComboBox and reload

void QComboBox::showPopup ()

very simple example

MyComboBox::MyComboBox(QWidget *parent) : QComboBox(parent)

void MyComboBox::showPopup()
view()->setFixedSize(300, 300);

7th August 2008, 18:39
I will give that a try. Thanks!

21st August 2008, 13:16
That worked!!! Thanks again!