[Qt-interest] How to resize QListView to contents ?
Tom Panning
lurchvt at gmail.com
Fri Feb 6 23:04:53 CET 2009
On Sun, Jan 25, 2009 at 7:11 PM, Vladimir Romanovskiy
<Vladimir.Romanovskiy at swissrisk.com> wrote:
> Hi,
>
> I have a QComboBox inside a QToolBar. I want popup QListView that is
> part of the combo box to be resized to its longest item, rather then to
> stay with fixed size of the combo box?
> QListView has to show items in full length.
We had to do this for our application, and our solution was subclass
the QStyle and reimplement QStyle::subControlRect() for
SC_ComboBoxListBoxPopup to return the width of the widest item (which
happens to be the size hint of the first column in the combox's view).
If you do this, don't forget to add space for the vertical scroll bar
if it is present.
I'm not sure if this is the best way, but it is how we did it,
Tom
More information about the Qt-interest-old
mailing list