Reputation: 179
I want QComboBox size to be more than 1. By default it is 1. From "size" I mean It should show more than one options at a time without mouse-click on comboBox. I could not find any function on QComboBox Doc. For what behaviour I want can be understood by this html code.In HTML it is done this way.
<select size="3">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
Link to this source . Look at the result on right side.
What should I do to achieve such a "Select from list" functionality in qt?
Upvotes: 2
Views: 358
Reputation: 18504
You can't do this. QComboBox
is just a QLineEdit
with down-arrow button, popup menu(view) which described by model (QStandardItemModel
etc).
QLineEdit
doesn't allow you to show more then one line.
You should use QListWidget
for easy tasks and QListView
for harder tasks. It is very similar to your example.
You can get links from @thuga's
comment. Documentation contains all necessary things such as itemChanged ( QListWidgetItem * item )
signal and other examples.
I think that the maximum what you can achieve with QComboBox
is just keep this comboBox
open every time. Use showPopup()
method for this.
Upvotes: 2