[Qt-interest] Feature request: implement QAbstractItemModel::span(...), and "QParametersTreeView"

Neil Girdhar mistersheik at gmail.com
Fri May 1 04:34:30 CEST 2009


Update:

I tried looking at how other people were implementing parameter panes in all
kinds of standard dialogs.  One of the dialogs that stuck out was the file
info dialog (apple-i in the finder), which is implemented by a tree.  And
then it hit me-- I'm trying to separate a model from a view, so I need to
use the model/view paradigm.  Awesome.

There are two unfortunate problems with implementing parameter panes (like
the file info dialog) in Qt:

Most rows are split into two columns: label and value widget, but the
section headings need to span both columns.  QAbstractItemModel::span(...)
is not implemented used yet, unfortunately.

Also, the problem with a hand-crafted parameter pane is that it won't follow
the OS guidelines.  There should be a specialized view with two columns,
that does QFormLayout for the parameters, and lets the section headers span
both columns, say "QParametersTreeView".

Keep up the good work Qt people!

Neil

2009/4/29 Neil Girdhar <mistersheik at gmail.com>

> Hi all,
>
> I'm trying to implement a parameter pane with a whole bunch of controls for
> parameters.  Sometimes the user interacts with the parameter pane, and then
> any corresponding values in the program need to be changed.  Sometimes the
> program progresses to a new state, and the UI needs to be updated.  This is
> complicated by the fact that one parameter pane item (a QWidget) might point
> to many values underneath.
>
> I have included a snippet of my code that illustrates what I am trying to
> do.  However, it's clear to me that there must be a better way to do this.
>
> Also, how do I call valueChangedUnderneath for all child QWidgets in a
> hierarchy?  Is there an easy way to use the custom event system to do this?
>
> Thanks so much in advance!
>
> Neil
>
> ps I am using Qt4.4 and C++ 0x, but that shouldn't matter.
>
> class ValueWriterDouble: public QDoubleSpinBox {
>     Q_OBJECT
>
> public:
>     ValueWriterDouble(vector<double*> const& value): myValue(value) {
>         QObject::connect(this, SIGNAL(valueChanged(double)), this,
> SLOT(valueChanged(double)));
>        }
>     ~ValueWriterDouble() {}
>
> public slots:
>     void    valueChanged(double new_value) {
>         for (auto it = myValue.begin(); it != myValue.end(); ++it)
>             **it = new_value;
>     }
>
>     void    valueChangedUnderneath() {
>         if (myValue.empty()) {
>             CHECK(false);
>             return;
>         }
>         bool consistent = true;
>         double desired_value = *myValue.front();
>         for (auto it = myValue.begin(); it != myValue.end(); ++it)
>             if (*it != desired_value) {
>                 consistent = false;
>                 break;
>             }
>         if (!consistent) {
>             // blank the widget text
>         } else {
>             // set the widget text and value to desired_value
>             setValue(desired_value);  // this causes an unnecessary
> valueChanged event
>         }
>     }
>
> private:
>     vector<double*>         myValue;
> };
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090430/a283aeaf/attachment.html 


More information about the Qt-interest-old mailing list