Add step parameter to DoubleInput QInputDialog
David Faure
faure at kde.org
Fri May 10 07:14:28 UTC 2013
On Wednesday 08 May 2013 17:26:17 David Gil Oliva wrote:
> Hi!
>
>
> 2013/5/2 David Faure <faure at kde.org>
>
> > On Thursday 02 May 2013 13:07:34 David Faure wrote:
> > So the real solution is not to add getItemList to Qt, but rather to change
> > Qt's getItem to use a QListView rather than a QComboBox, in order to
> > improve usability.
> >
> > And meanwhile we can deprecate getItemList in favour of Qt's getItem.
>
> After studying the code, I came to the conclusion that that can't be really
> done for the following reasons.
>
> --QInputDialog has QComboBox as the default widget for item lists. The
> method for setting the items is not setItems, but setComboBoxItems. After
> that, a QListView can be set modifying the options.
>
> QInputDialog dialog;
> dialog.setComboBoxItems(list);
> dialog.setOptions(QInputDialog::UseListViewForComboBoxItems);
Oh, I didn't know that one could do that.
> --The parameters of getItem are:
>
> QString QInputDialog::getItem(QWidget *parent, const QString &title, const
> QString &label,
> const QStringList &items, int current, bool
> editable, bool *ok,
> Qt::WindowFlags flags, Qt::InputMethodHints
> inputMethodHints)
>
> That "editable" is only for QComboBox, not for QListView.
Indeed.
> --The method ensureListView calls ensureComboBox and then sets the model of
> the comboBox to the listView.
> The listView depends on the existence of the comboBox.
That's internal, though.
> --The listView occupies much more space than the comboBox.
Sure, having both options is good.
> Therefore, I think that it would be best to add a static method called
> getItemFromListView. What do you think?
Option 1: adding getItemFromListView (the name looks a bit odd)
Option 2: adding a getItem overload that takes an InputDialogOptions
parameter, so that this will be ready for more options if any, in the future.
Option 3: porting coded to the multi-line call (constructor, setComboBoxItems,
setOptions).
In my opinion option 2 is best if not too ugly (not sure where to add the
additional argument, depends how many default values there are etc.),
otherwise option 3 (depending on how many calls to getItem we actually
have...).
--
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5
More information about the Kde-frameworks-devel
mailing list