How to determine in MainWindow's mouseReleaseEvent() whether mouse is over a specific widget
-
I used images. For each custom widget, i used the render() function to make it draw a
pixmap (thumbnail) i then used in the list.While you can use ListWidget and setItemWidget, it is very heavy and
listView + delegate is recommended.
If you only have few items and its on Desktop pc, then setItemWidget
works ok but for many items, delegate is the way to do it.
Alternativt, scrollarea can also be used for a list of widgets. but really depends
on how many items u have.@mrjj
Ok, so using a delegate class with the ListView would be the best way, if I understood correctly.
I unfortunately can't use jsut a thumbnail pixmap, the user should be able to interact with the widget and the widget should be able to display many things (but every item I add to the ListView would be from the same widget class, otherwise I could not use a ListView, I have read).
Would I still have these handeling features in a ListWidget like drag and drop in the ListView? If yes, is it more easy to implement this in a ListWidget or does it not really make a difference? -
@mrjj
Ok, so using a delegate class with the ListView would be the best way, if I understood correctly.
I unfortunately can't use jsut a thumbnail pixmap, the user should be able to interact with the widget and the widget should be able to display many things (but every item I add to the ListView would be from the same widget class, otherwise I could not use a ListView, I have read).
Would I still have these handeling features in a ListWidget like drag and drop in the ListView? If yes, is it more easy to implement this in a ListWidget or does it not really make a difference?@Niagarer
It will have drag & drop support but its ment for the normal items and if u have full blown
widgets instead, you will need to add support for those.
The delegate must be able to draw (in code) the looks of the real widget so
if its complex widgets, it will be tons of work.
But yes it could work.How many of these custom widgets are we talking about?
-
@Niagarer
It will have drag & drop support but its ment for the normal items and if u have full blown
widgets instead, you will need to add support for those.
The delegate must be able to draw (in code) the looks of the real widget so
if its complex widgets, it will be tons of work.
But yes it could work.How many of these custom widgets are we talking about?
-
@mrjj
If I'm unlucky, one day it could go to a thousand.
So I should not use a ListWidget if I understood correctly, but a ListView will be tons of work...
:/
I thought, this would not be such a big problem >.< -
@Niagarer
Then both setItemWidget and ScrolLArea will potentially be very slow.
Depending on the hardware it must run on. The memory alone will be high.Are all those different ?
@mrjj
Well the widget objects will come from the same class. What I mean is that I display only widget objects from f.e. MyWidget-class but with different text shown, and a different icon and some more different icons I will add to the widgets in the MyWidget-class, but the class is just one. (Actually I wanted to make two different ones for a QTreeWidget, but I guess I sould avoid that, it seems to be hard...)
Yes, actually I wanted to make it runnable on very slow hardware -
@mrjj
Well the widget objects will come from the same class. What I mean is that I display only widget objects from f.e. MyWidget-class but with different text shown, and a different icon and some more different icons I will add to the widgets in the MyWidget-class, but the class is just one. (Actually I wanted to make two different ones for a QTreeWidget, but I guess I sould avoid that, it seems to be hard...)
Yes, actually I wanted to make it runnable on very slow hardware -
Do you have a picture of what you want ?
-
@mrjj
In the end I would really like to have something like this:

With the List I want only to represent the content inside the green rect.
I think I will not need the tree structure, only these widgets with f.e. this f, because once this list gets very big, only the search function will be used anymore (but if it is completele a joke to implement it with a treeList after I get it work with the ListView, I would appreciate it). But I would like to add some more little icons like that at the right side of the widget. -
@mrjj
In the end I would really like to have something like this:

With the List I want only to represent the content inside the green rect.
I think I will not need the tree structure, only these widgets with f.e. this f, because once this list gets very big, only the search function will be used anymore (but if it is completele a joke to implement it with a treeList after I get it work with the ListView, I would appreciate it). But I would like to add some more little icons like that at the right side of the widget. -
@mrjj
Thats a tooltip, the mouse was over the Get Blackboard thing and on the left of the widget there is also shown a little pushButton (the little star) to mark it as favourite (because the mouse was over this component).Ok. i think a delegate will work super since its relatively simple structure.
We often refer to
http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
for delegate sample -
Ok. i think a delegate will work super since its relatively simple structure.
We often refer to
http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
for delegate sample -
@mrjj
In the example, a QTableWidget is used. And so it has no model (no QAbstractItemModel, the struct is actually the model). Would all this also work with QListViews or QTableViews?@Niagarer
Yes the delegate is the same regardless of the view/widget used.
http://doc.qt.io/qt-5/model-view-programming.htmlThe delegate can be seen as way to custom paint.