[Qt-interest] ISO Model/View Solution for scrolling list of widgets
KC Jones
kc at asperasoft.com
Thu Oct 29 16:42:49 CET 2009
Nice to hear that I'm struggling with a real problem instead of
missing something obvious! Thanks for the feedback and ideas, Ian and
André.
The KDE classes look like a good fit. I'm already making heavy use of
QSql and related models. I have a model half baked for this purpose.
Looks like it does what I want.
But in the interest of using fewer moving parts and sticking with the
published framework -- and because this subset of my app should not
involve excessively large datasets (until QA starts probing the
boundary conditions!) I'm leaning towards Ian's QScrollArea approach.
I've already played around with Ian's scroll area approach and it
presents the desired widgets and layouts exactly as I need them. What
is missing is the model integration and the view class optimizations.
That is not trivial, but I'm inclined to ignore this, ditch my model,
assume small-enough query result sets that I can manage this myself.
I could come to regret this, eh?
But I will keep an eye on the ItemViewsNG work. This is my 2nd major
development effort using the model/view framework and I gotta believe
it could be improved in many ways -- and not just in the context of
this problem. The conceptual model behind these model/view classes is
not obvious to me and I find myself struggling to achieve many things.
I'm guessing that really fixing this framework cannot be done
compatibly and will require some fresh thinking.
For now I will muddle through and at least be content to know I'm not
missing some obvious better way using the existing framework.
On Thu, Oct 29, 2009 at 1:02 AM, Andre Somers <andre at familiesomers.nl> wrote:
> KC Jones wrote:
>> I'm struggling with an implementation problem that I hope someone here
>> can help me with.
>>
>> I have an application that needs to implement something like the
>> FireFox Downloads window. Behind this is a model that describes the
>> items with various strings, files paths, progress data. The number of
>> items and their data vary in real time, all captured in a
>> QSqlTabelModel. Through this UI I need to provide controls very
>> similar to the stop/start/cancel controls on the FF download window.
>>
>> Using QListView + QStyledItemDelegate + custom editor widget seems
>> natural. I have this sketched in. (QTreeView is out since the custom
>> widget cannot live with a simple column oriented layout.) The
>> selected/edited item represented by my custom editor widget looks
>> good. My problem is that every item in the list really wants to be an
>> instance of that widget. Selected or not, I want every item to
>> display the same data in the same way. I could live with requiring
>> the user to select an item for the "editor" widget to be enabled. But
>> I want all rows to use the same custom widget definition to display
>> itself.
>>
>> So is there a way in QStyledItemDelegate::paint() to leverage my
>> custom widget's paint impelementation directly? Or else make use of
>> the custom widget's layout to at least simplify my paint() method?
>> I've also looked at writing my own ScrollingWidgetList widget derived
>> from QScrollArea, but that seems like a major project. I'm hoping
>> there are simpler solutions.
>>
>> This seems like a fairly generic problem. If this is in some docs or
>> tutorials or samples, please clue me in.
>>
>>
> Yes, it is a generic problem. But it is not all that easy to solve.
> In Qt Labs, there is a project called ItemViewsNG. It is a new take on
> the whole ItemView idea, and it has the potential to make this kind of
> thing much easier. Perhaps it already does what you need; I have not
> personally tried it recently but I have seen the presentation on the Qt
> Developers Days and talked with the developer a bit.
> Another approach you can use (and this is what I currently do) is to
> leverage the work that has been done by KDE on this. KDE developed this
> under the name Goya, and it is now known as KWidgetItemDelegate. It
> makes it possible to use widgets in your item views. It is not perfect,
> but it works. You can find the code in the KDE repository. Note it is
> licenced as LGPL.
>
> See
> http://techbase.kde.org/Development/Tutorials/Introduction_to_Goya_usage
> for some information on how to use it, next to the API docs
> http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKWidgetItemDelegate.html
>
> André
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list