Results 1 to 3 of 3

Thread: Subclassing QTableView

  1. #1
    Join Date
    Feb 2007
    Location
    Wroclaw, Poland
    Posts
    72
    Thanks
    6
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Subclassing QTableView

    I've created my own model with 10 roles to store data.
    Now I need to create view where each cell would be filled with my widget. This widget is build with other widget (like Labels, spins, etc).
    I've created my own view class based od QTableView - which methods I need to overload?
    I want to show all data from model at once, so ItemDelegate won't work.

    I know that I could use QTableWidget and setCellWidget() to set my own widgets inside each cell. I don't wont to do that.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Subclassing QTableView

    use
    Qt Code:
    1. void QAbstractItemView::openPersistentEditor ( const QModelIndex & index )
    To copy to clipboard, switch view to plain text mode 

    but performance of your app will decrease.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclassing QTableView

    Quote Originally Posted by T4ng10r View Post
    I want to show all data from model at once, so ItemDelegate won't work.
    Sure it will. I don't know what exactly you want to do but either you want to implement a custom item delegate or you want to avoid using QTableView If you really, really, really need real widgets, then use QScrollArea instead of QTableView. Otherwise if you just want the looks and/or a limited amount of user interaction (like clicking here and there), implement a custom delegate that will use QStyle primitives to draw the looks of widgets.

Similar Threads

  1. QTableView sizeHint() issues
    By akos.maroy in forum Qt Programming
    Replies: 3
    Last Post: 20th September 2008, 22:42
  2. Replies: 1
    Last Post: 16th May 2008, 20:31
  3. make QTableView work as a multi-column list view
    By wesley in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2008, 14:43
  4. QTableView Row Selection
    By ToddAtWSU in forum Qt Programming
    Replies: 8
    Last Post: 12th December 2007, 21:27
  5. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49

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.