Results 1 to 4 of 4

Thread: select more than one row in table widget using pyqt

  1. #1
    Join Date
    Jul 2009
    Posts
    2
    Qt products
    PyQt3 PyQt4
    Platforms
    Windows

    Default select more than one row in table widget using pyqt

    I'm some kind of desperate.
    I use a table widget in pyqt to list some items for the user. The user is able to select some filenames in a filedialog and add them to the table by using a button. I also want the user to be able to change some properties of the items he just added.
    Therefor I want the items, which the user added, to be selected. No Problem, if the user just add one item, but I really don't get it, how to select more than one row in the table by code. (the adding of the items to the table no problem too)
    Just using qttable.selectRow(..) more than once lead to a error called
    "Exception RuntimeError: 'maximum recursion depth exceeded in __subclasscheck__' in <type 'exceptions.RuntimeError'> ignored"
    I tried to change the selectionMode to extendedselection or multi, but that obviously did not work out too.
    I read some stuff about using itemmodel and itemselectionmodel, but I really didn't get it how to use these functions and even not, if I can reach my goal with using them.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: select more than one row in table widget using pyqt

    Have you tried to use the selection model direct via QAbstractItemView::selectionModel()?

  3. #3
    Join Date
    Jul 2009
    Posts
    2
    Qt products
    PyQt3 PyQt4
    Platforms
    Windows

    Default Re: select more than one row in table widget using pyqt

    thats a function i have found, but wasn't really sure about how to use and functionality.
    But that's at least a hint.
    So I will read more about, maybe I will get it
    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: select more than one row in table widget using pyqt

    Quote Originally Posted by parkourpenner View Post
    So I will read more about, maybe I will get it
    Qt Code:
    1. tableWidget->selectionModel()->select(tableWidget->model()->index(0,0), QItemSelectionModel::SelectCurrent|QItemSelectionModel::Rows);
    2. tableWidget->selectionModel()->select(tableWidget->model()->index(1,1), QItemSelectionModel::Select|QItemSelectionModel::Rows);
    To copy to clipboard, switch view to plain text mode 
    to select row 1 and 2...

Similar Threads

  1. Replies: 0
    Last Post: 8th July 2009, 11:01
  2. Replies: 0
    Last Post: 28th May 2009, 22:38
  3. Table Widget Vs. Table View
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2008, 09:56
  4. Replies: 4
    Last Post: 4th February 2008, 06:16
  5. customizing table widget
    By krishna.bv in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:43

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.