New representation (View) of a QStandardItemModel
-
wrote on 9 Mar 2016, 13:25 last edited by
Hi,
I´m currently developing a program for creating trees. This itself wouldn´t be a problem, BUT:
I´m using the QStandardItemModel, that is totally enough for my needs.
I would like to create a widget, displaying the tree like shown in this IMAGE
As I understood the documentation, I have to reimlpement the QAbstractItemView. But is there any tutorial which methods to use for drawing the tree, getting signals when a node is clicked? With a simple example I could figure the rest out by myself. I just need a starting point.
Is there anybody who has done something similar?
Is it also possible to place widgets in nodes? Like:
MyNode [Image/logo] Button ______________ Thank you very much!
Martin -
Hi,
I´m currently developing a program for creating trees. This itself wouldn´t be a problem, BUT:
I´m using the QStandardItemModel, that is totally enough for my needs.
I would like to create a widget, displaying the tree like shown in this IMAGE
As I understood the documentation, I have to reimlpement the QAbstractItemView. But is there any tutorial which methods to use for drawing the tree, getting signals when a node is clicked? With a simple example I could figure the rest out by myself. I just need a starting point.
Is there anybody who has done something similar?
Is it also possible to place widgets in nodes? Like:
MyNode [Image/logo] Button ______________ Thank you very much!
MartinModeratorswrote on 9 Mar 2016, 15:07 last edited by kshegunov 3 Sept 2016, 15:07@martinheidelberg
Hello Martin,
You might be better off switching to the graphics scene framework, it looks to be better suited to your needs. For a startup you could look here. That said you could probably do the painting in an abstract item view, but I believe it'll be much more hassle to implement.Kind regards.
-
wrote on 9 Mar 2016, 16:14 last edited by
Thank you for your reply!
That was my wayB. I will probably do that and go with the graphics scene framework! I just thought, that there is a nicer version with the Model/View Framework.
-
Thank you for your reply!
That was my wayB. I will probably do that and go with the graphics scene framework! I just thought, that there is a nicer version with the Model/View Framework.
@martinheidelberg said:
I just thought, that there is a nicer version with the Model/View Framework.
No, at least not an easy way as far as I know, since you'd want a pretty heavily custom painting. I believe it possible, but still doubt the wisdom of it, because the graphics view framework is quite better tailored for tasks such as yours.
Kind regards.
-
@martinheidelberg said:
I just thought, that there is a nicer version with the Model/View Framework.
No, at least not an easy way as far as I know, since you'd want a pretty heavily custom painting. I believe it possible, but still doubt the wisdom of it, because the graphics view framework is quite better tailored for tasks such as yours.
Kind regards.
wrote on 10 Mar 2016, 08:16 last edited bySince I already worked with the graphics framework, I will stick with it!
Thank you both for your posts. It saved me a lot of time trying ;)solved
5/5