PDA

View Full Version : Qt input dialog list view


zolakt
2010-05-09, 12:11
Hi,
I have a QInputDialog in which the user selects some options.
The thing I don't like is that it displays a combobox in the dialog.
Then you have to click on the combobox, and another dialog appears where you can select your value.

Is it possible to get rid of the combobox, and have only the selection list in the first dialog.

Maybe some screenshots will clarify:
This is what I have now:
http://img59.imageshack.us/img59/2263/screenshot2010050913583.png

And this is what I would like it to look like:
http://img301.imageshack.us/img301/4440/screenshot2010050914013.png

Btw. I'm using python
My current code:
items = QtCore.QStringList()
items << "Female" << "Male"

item, ok = QtGui.QInputDialog.getItem(self, 'Select voice type', "", items, 0, False)

krk969
2010-05-09, 12:28
try using a QDialog (http://doc.trolltech.com/4.6/qdialog.html) or subclassing it.

In a QDialog you could add whatever widget suits you, in this case it seems to me you would like something that could be checked.
Perhaps QRadioButton or QCheckbox might help.

zolakt
2010-05-09, 12:32
Hmmm...I'd like to avoid creating another custom dialog.

But regardless, radio buttons are not the way.
They are poorly ported, for this use, anyway.
They look like "normal radio buttons", and I couldn't get them to expand horizontally, so you have to click on the (very) little circle, or the label to select.
Checkbox is also not the answer, because I don't need multiple selection

I was hopping I could just pass some flag to QInputDialog.

krk969
2010-05-09, 12:46
Hmmm...I'd like to avoid creating another custom dialog.

But regardless, radio buttons are not the way.
They are poorly ported, for this use, anyway.
They look like "normal radio buttons", and I couldn't get them to expand horizontally, so you have to click on the (very) little circle, or the label to select.
Checkbox is also not the answer, because I don't need multiple selection

I was hopping I could just pass some flag to QInputDialog.

well radio buttons are properly implemented in maemo5 style(unless you have changed styles in your app) to be big and large with a default height of 70px I think just like a pushbutton.
You can change the width with setMaximumSize (http://doc.trolltech.com/4.6/qwidget.html#maximumSize-prop).

Even the checkbox is the same case albeit its a bit smaller. :)

You can switch off multiple selection in both setting the auto exclusive property (http://doc.trolltech.com/4.6/qabstractbutton.html#autoExclusive-prop)