Results 1 to 8 of 8

Thread: Model/View Question

  1. #1
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Model/View Question

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Model/View Question

    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.

  3. The following user says thank you to Santosh Reddy for this useful post:

    meazza (19th May 2011)

  4. #3
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Model/View Question

    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.

  5. #4
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Model/View Question

    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?

  6. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Model/View Question

    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

  7. #6
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Model/View Question

    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
    Attached Images Attached Images

  8. #7
    Join Date
    Jun 2014
    Posts
    98
    Thanks
    43
    Thanked 4 Times in 4 Posts
    Platforms
    Windows

    Default Re: Model/View Question

    Quote Originally Posted by meazza View Post
    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.

  9. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,787
    Thanks
    263
    Thanked 773 Times in 763 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Model/View Question

    Since it has been 3 1/2 years since the question was posted, I doubt whether starting a new thread would be useful.

Similar Threads

  1. Model/View Programming: a question about data
    By QAlex in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2009, 19:43
  2. Model / View - Design Question
    By antarctic in forum Qt Programming
    Replies: 8
    Last Post: 8th June 2009, 08:39
  3. model/view editing question
    By KShots in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 18:52
  4. A question about Model/View programming
    By awhite1159 in forum Qt Programming
    Replies: 5
    Last Post: 15th June 2008, 16:38
  5. General Question about Qt4 Model/View
    By reed in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 16:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.