Custom editor for a delegate
-
-
So any suggestions how i do this painting over? I suppose i have to somehow get the coordinates of the cell, then draw a barebone widget und maybe adjust it in the tableview frame. But i dont know where to start. Are there some examples on that?
@Maser
Hi,
Maybe you should look into a delegate ?
http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.htmlA delegate is the normal way to change how content is drawn in each cell.
Painting on the actual view will often have side effects with scrolling etc.
If you want to see, you will override the paintEvent virtual function
and paint there. -
Im using a delegate. but i want the editor of the delegate drawn over the cell. I just need a hin how i connect the coordinates and draw a barebone widget. In wont have to be scrollable (yet).
Ok. Im not really following what u need. sorry.
In any case, you can override paintEvent for any widget and draw.
Notice that you cannot draw outside of the widgets client area so
make sure u override the paint for the actual widget u want to draw on. -
It seems overriding paintevent doesnt work. What does work(at least partially) is reimplementing updateEditorGeometry from the delegate. When i give the specific cell a bigger size for the editor it paints it bigger. Even the choosing works, but not when there is another cell under from the tableview under my editor-buttons. Dont yet know how to solve that.
-
It seems overriding paintevent doesnt work. What does work(at least partially) is reimplementing updateEditorGeometry from the delegate. When i give the specific cell a bigger size for the editor it paints it bigger. Even the choosing works, but not when there is another cell under from the tableview under my editor-buttons. Dont yet know how to solve that.
-
http://www.picfront.org/d/9q7X
I marked the cell from which the editor has been activated. Problem is, as long is the items are of this cell or outside of the table, i can click them. if the are above other cells, the editor closes. -
http://www.picfront.org/d/9q7X
I marked the cell from which the editor has been activated. Problem is, as long is the items are of this cell or outside of the table, i can click them. if the are above other cells, the editor closes.@Maser
Could you not just pop a dialog with
all the images and let user select one?Or use a combobox with a delegate ?
http://www.qtcentre.org/threads/26376-Using-images-in-QComboBox -
This is a good idea)
But since im trying to learn Qt, i will save it for the emergency plan)
When i have a customer who wants it the exact way he described it, i wanna know how to do it, no matter of the cost)
Have you an idea why the over cells interfere with my editor and how i can solve it? -
This is a good idea)
But since im trying to learn Qt, i will save it for the emergency plan)
When i have a customer who wants it the exact way he described it, i wanna know how to do it, no matter of the cost)
Have you an idea why the over cells interfere with my editor and how i can solve it? -
No, i can. I told you. if i aim right in the black marked cell, i can click and unclick the three left items, i can also click the three right items. Just when i click anywhere in the tablecells, the editor is gone.
PS: Maybe i have to somehow resize the "working area" of the cell to to fit my editor. I mean the clickable area associated with the cell. Idea on that?
-
No, i can. I told you. if i aim right in the black marked cell, i can click and unclick the three left items, i can also click the three right items. Just when i click anywhere in the tablecells, the editor is gone.
PS: Maybe i have to somehow resize the "working area" of the cell to to fit my editor. I mean the clickable area associated with the cell. Idea on that?
-
class ClickableIconHolder : public QWidget { Q_OBJECT public: ClickableIconHolder(uint Mark, QWidget *parent = 0); QSize sizeHint() const Q_DECL_OVERRIDE; signals: void editingFinished(); protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: QHBoxLayout *hbLayout; ClickableIcon *ci1 = 0; ClickableIcon *ci2 = 0; ClickableIcon *ci3 = 0; ClickableIcon *ci4 = 0; ClickableIcon *ci5 = 0; ClickableIcon *ci6 = 0; ClickableIcon *ci7 = 0; };
Here is the header of the editor-widget. I create some clickable QLabel and add them to a HBoxLayout, thats all in general. I dont do nothing in the paintevent yet.
-
I tried to go cardcore and draw the widget myself, with no parent pased to it, but the problem is, the delegate doesnt wait for my editor to pass the data, whem im not making the editor delegates child. Im afraid for that id have to dig deep in the delegates sourcecode...
-
I tried to go cardcore and draw the widget myself, with no parent pased to it, but the problem is, the delegate doesnt wait for my editor to pass the data, whem im not making the editor delegates child. Im afraid for that id have to dig deep in the delegates sourcecode...
-
Nah, that would be a waste of time at this point. I just took QDialog as a parentclass to my editor, now i can click everything and after i positioned it, it stays where it should be. Im not done yet completly implementing it, but the appearance(apart of some big margins for the boundaries) is quite what i wanted.
Thanks so far)) -
Nah, that would be a waste of time at this point. I just took QDialog as a parentclass to my editor, now i can click everything and after i positioned it, it stays where it should be. Im not done yet completly implementing it, but the appearance(apart of some big margins for the boundaries) is quite what i wanted.
Thanks so far)) -
http://www.picfront.org/d/9q8q
That is the look now. I added a Qt::FramelessWindowHint flag and this seems to be the minimal size. I have not figured out yet how to reduze the margins. -
http://www.picfront.org/d/9q8q
That is the look now. I added a Qt::FramelessWindowHint flag and this seems to be the minimal size. I have not figured out yet how to reduze the margins.@Maser
Ok . looks nice.
Did you use a layout ?
It has margins.
http://doc.qt.io/qt-5/qlayout.html#setContentsMargins"On most platforms, the margin is 11 pixels in all directions."