Add step parameter to DoubleInput QInputDialog

David Gil Oliva davidgiloliva at gmail.com
Wed May 8 15:26:17 UTC 2013


Hi!


2013/5/2 David Faure <faure at kde.org>

> On Thursday 02 May 2013 13:07:34 David Faure wrote:
> > > BTW, the definition of QInputDialog says that it "provides a simple
> > > convenience dialog to get a single value from the user." The future new
> > > method getItemList will be able to return more than one value (in a
> > > QStringList, for example). It will force me to change the documentation
> > > and
> > > the definition. We will see, what the reviews say.
>
> Hold on, Kévin and I just had a look at all the users of getItemList, to
> see
> if it was really used.
>
> It turns out that it *is* used (in knewstuff, kile, kmymoney and libkcddb),
> but in all cases, the application then takes the first one out of the
> returned
> list!
> Why don't they just use getItem then? The answer: because getItem shows a
> closed combobox, while getItemList shows a much nicer flat list, which
> shows
> multiple items to the user.
>
> 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);

--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.

--The method ensureListView calls ensureComboBox and then sets the model of
the comboBox to the listView.

Q_Q(QInputDialog);
    if (!listView) {
        ensureComboBox();

        listView = new QListView(q);
        listView->hide();
        listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
        listView->setSelectionMode(QAbstractItemView::SingleSelection);
        listView->setModel(comboBox->model());

The listView depends on the existence of the comboBox.

--The listView occupies much more space than the comboBox.

Therefore, I think that it would be best to add a static method called
getItemFromListView. What do you think?

Best regards,

David Gil
www.hackingastrology.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20130508/017bf8c6/attachment.html>


More information about the Kde-frameworks-devel mailing list