Results 1 to 9 of 9

Thread: QTableView Row Selection

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Red face QTableView Row Selection

    I have just upgraded from Qt 4.1.4 to Qt 4.3.0 and am having a few bugs. I have a QTableView that holds a bunch of QVariant data. I have it set up so the user selects the whole Row when they click on a cell. This was working fine in Qt 4.1.4, but now it somewhat works in Qt 4.3.0. What happens now is when I click and drag to select multiple rows, the first row is selected correctly, but subsequent rows only highlight the first cell of the row. Some of the rows have a thin black selection line underneath some of the other cells in the selected row. However, if I pull a window to the front of the screen and then bring the window containing my QTableView back to the front, forcing a redraw, all the selected rows are highlighted correctly. I have tried calling a repaint call on the QTableView when I release the mouse button, but this did not fix the call. Does anybody have any ideas why this worked fine in Qt 4.1.4 but not now in Qt 4.3.0? My code is on a standalone Solaris and the only way I can get the code off it is to print it and retype it, which I would prefer to not do unless it is necessary. Thanks for your help!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableView Row Selection

    Quote Originally Posted by ToddAtWSU View Post
    I have just upgraded from Qt 4.1.4 to Qt 4.3.0
    Just out of curiosity, why half a year old 4.3.0 now that several bug fix releases for the 4.3 series are already out?
    J-P Nurmi

  3. #3
    Join Date
    Sep 2007
    Posts
    7
    Thanked 1 Time in 1 Post

    Default Re: QTableView Row Selection

    do you use slelection model or select is on your own?

  4. #4
    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: QTableView Row Selection

    Quote Originally Posted by ToddAtWSU View Post
    Does anybody have any ideas why this worked fine in Qt 4.1.4 but not now in Qt 4.3.0? My code is on a standalone Solaris and the only way I can get the code off it is to print it and retype it, which I would prefer to not do unless it is necessary. Thanks for your help!
    I'd suggest upgrading to 4.3.3 first and checking if the error persists. Then (if it does) please tell us whether you modify the model during the life of the application. You can't select items which return invalid QVariant values for DisplayRole - maybe that's your case. If you modify the model (returning proper data for those items), it could "repair" the selection.

  5. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Row Selection

    I cannot upgrade to 4.3.3 right now due to requirements. I was lucky to get to move from 4.1.4 to 4.3.0. I am pushing to get approval to upgrade to 4.3.3, but I don't have it yet. It doesn't make sense to me why it worked great in 4.1.4 but not now in 4.3.0. Why would something break that was working.

    I don't manaully set the selection. I just told it to select the entire row when a cell was clicked on. I do emit a signal on the mouseRelease event so the parent holding the QTableView can do further calculations when a row is selected, but nothing that influences the table. The table is not being modified in anyway when a selection occurs. To me the confusing part is the first row I select updates correctly, highlighting the whole row, but subsequent rows do not.

    I doubt I have added any substance to my first post besides stating why I am not at 4.3.3 yet, but I am sorry I am not with 4.3.3 but when higher beings set the requirements, it is hard to get them to allow changes sometimes. So until then this is what I am stuck with. Thanks again for your help!

  6. #6
    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: QTableView Row Selection

    Could you post a minimal compilable example reproducing the problem? We'll try to run it on newer versions of Qt to see whether the problem was resolved.

  7. #7
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Row Selection

    I can try to come up with one but it could take a bit as I have a QVariantDataModel that stores my data. And then I call the setModel on this to store the data. However, this appears to be working fine since it has no influence on the QTableView selection at all.

    But in the meantime, can you explain why calling repaint( ) or update( ) on the table or dialog doesn't work, but bringing a secondary window to the front over the window with the table, forcing the table to redraw, causes the rows to be highlighted correctly? Thanks!

  8. #8
    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: QTableView Row Selection

    QVariantDataModel? Does it differ from QStandardItemModel?

  9. #9
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Row Selection

    Well I figured out my problem. I originally had the table displaying 6 columns of data and had the selection set to NoSelection. After I would hit a load button, I would add 2 more columns of data to the table and then allow MultiSelection once the data was loaded. I would reset the table headers to add on these last 2 columns headers and this was where my problem came in at. I did not have the "beginInsertColumns" and "endInsertColumns" calls being made around setting the titles and adding the columns. So my selection thought I was trying to select 8 columns and the table only had 6 columns. Once I fixed the problem to make sure all 8 columns were showing, the selection fixed itself because there were a proper number of columns. Thanks for your help and I guess the "beginInsert" calls are more strict in Qt 4.3.0 than in Qt 4.1.4. Thanks again though!

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  2. QTableView selection problem
    By aiprober in forum Qt Programming
    Replies: 12
    Last Post: 9th June 2008, 11:55
  3. QTableView row selection
    By davemar in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2007, 14:39
  4. Model sorting vs. selection
    By VlJE in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 16:46
  5. CheckBox and selection in QTableView
    By Mike Krus in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2006, 20:31

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.