PDA

View Full Version : Model/View Question



meazza
18th May 2011, 14:55
Hello fellow programmers.

I have attached an example of something similar to what I want to create in my application. Have been reading the tutorials and documentation of model/view for hours now and still cant decide which approach to take.

What I want is to have a model/view inside a QDockWidget and here I can change the values and these will control the "selected widget". In my model/view I want to have spinboxes, maybe some color chooser widget, some string and int values.

So my question here is what approach to take. I am thinking about using the allready finished classed like QTableWidget. But dont know if this is optimal if I want to use the table as a controll.

Hopefully someone can point me in the right direction.

Santosh Reddy
18th May 2011, 20:41
Looks like you want to have somthing like widget property editor, which will change the visual appreance of the widget itself inturn.

I would recommed to use QTableView in QDockWidget, and implement a model based of QAbastractModel and set it to QTableView, this way you can scale the model to support various types of widgets, having QTableWidget will laydown many restrictions in scaling the model.

meazza
19th May 2011, 09:00
Looks like you want to have somthing like widget property editor, which will change the visual appreance of the widget itself inturn.

Yes that is what I am going for and thank you for your tip I will try it out.

meazza
19th May 2011, 15:22
I have antother question regaring the the QAbstractTableModel. Is it somehow bad to call the reset() to update the view? Because I am changing some data outside the setdata function and then I would like the view to update it self. It does this if I click on it if I dont call reset().

So my question here is there are smarter way to do this? I know about the dataChanged() signal but all it does aswell is call reset() or?

Santosh Reddy
19th May 2011, 18:02
You can use beginResetModel() and endResetModel()

call beginResetModel() before editing the model data and
call endResetModel() after editing the model data (instead of reset)

You can always refer to

meazza
6th July 2011, 09:28
Reviving this thread again because I have another Model/View question. Take a look at the attachment for what I am trying to accomplish.

And what I want this view to contain is basically all the items I add to a QGraphicsScene. And trough this view I want to be able to select the items, hide them or remove them.

Basically it is an object list where the objects in the list are linked to the objects in the scene. And thought I would ask here first to see what you recommend for me to use. I have been looking at QListView but don't know. Also I want a context menu for all items in the view so if I right click I get a menu with some actions. So probably I need a custom delegate.

Hopefully you got some advice

neuronet
24th January 2015, 18:36
Reviving this thread again because I have another Model/View question. Take a look at the attachment for what I am trying to accomplish.

And what I want this view to contain is basically all the items I add to a QGraphicsScene. And trough this view I want to be able to select the items, hide them or remove them.

Basically it is an object list where the objects in the list are linked to the objects in the scene. And thought I would ask here first to see what you recommend for me to use. I have been looking at QListView but don't know. Also I want a context menu for all items in the view so if I right click I get a menu with some actions. So probably I need a custom delegate.

Hopefully you got some advice

Seems a separate question I'd start a new thread.

d_stranz
25th January 2015, 18:14
Since it has been 3 1/2 years since the question was posted, I doubt whether starting a new thread would be useful.