Reputation: 673
I'm creating a program where the width of column needs to be relatively narrow, but when I add a combo box I have to increase the width so that I can read the listings in the drop down. I know that in HTML the drop down adjust to the length of longest entry, in Iron Python you can adjust the drop down width manually, but I can't seem to find any reference to either of these options in PyQt. If I'm missing it in the documentation, a friendly pointer to the right spot would be of great help. Thanks.
Upvotes: 1
Views: 4884
Reputation: 1175
The dropdown portion is a component that inherits QAbstractItemView
(usually QListView
).
It is accessible via the view()
getter of the QComboBox
. You can play with its sizePolicy to get what you want.
If it is not satisfying, you can even set your own QAbstraItemView
to the QComboBox
via `setView'.
Upvotes: 2
Reputation: 46509
In Qt a widgets size is usually controlled by its layout. The layout management docs should help. In particular, take a look at QSizePolicy. If you're using designer, you can set these directly as properties, otherwise you'll need to do it in code. The basic layouts example may help as well.
Upvotes: 0