Results 1 to 7 of 7

Thread: QTableView Problem

  1. #1
    Join Date
    Jun 2018
    Posts
    23
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QTableView Problem

    When I pass the cursor over a table using QTableView, a signal is emitted that invokes the rowCount () function of the QAbstractTableModel, even when I click on a cell, the data () function of the QAbstractTableModel is invoked, how can I disconnect the cursor signal when I am on a cell or click. I am confused that the rowCount () and data () functions are not slot functions.
    Thanks for help me.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,193
    Thanks
    236
    Thanked 667 Times in 657 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QTableView Problem

    I am confused that the rowCount () and data () functions are not slot functions.
    These can't be slots. They return a value to the caller (an int and a QVariant, respectively). Slots are void methods that can only "return" a value if they are passed a pointer or non-const reference as an argument.

    If your table cells are editable, then clicking on a cell will invoke the model's data() method to retrieve the value for the EditRole. If you are moving the mouse slowly enough, then data() could also be invoked without a click to retrieve the values for the StatusTipRole, ToolTipRole, or WhatsThisRole.

    If you are moving the mouse normally, then there should not be any calls into the model. Run your code in the debugger, set a breakppoint on rowCount(), and find out how it is being called by looking at the stack trace.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    459
    Thanked 63 Times in 59 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Problem

    Quote Originally Posted by d_stranz View Post
    If you are moving the mouse normally, then there should not be any calls into the model
    They are (depending on the style) since the current item is highlighted which triggers a redraw.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,193
    Thanks
    236
    Thanked 667 Times in 657 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QTableView Problem

    They are (depending on the style) since the current item is highlighted which triggers a redraw.
    Even when mouse tracking is disabled? That seems like a huge overhead - surely only the item under the cursor is the only one which must be redrawn, not the entire table.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    459
    Thanked 63 Times in 59 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Problem

    Quote Originally Posted by d_stranz View Post
    Even when mouse tracking is disabled? That seems like a huge overhead - surely only the item under the cursor is the only one which must be redrawn, not the entire table.
    As I said - it depends on the style, fusion and breeze do highlight the current cell under the cursor. I'm pretty sure that not the whole table is redrawn.

  6. #6
    Join Date
    Jun 2018
    Posts
    23
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QTableView Problem

    Quote Originally Posted by d_stranz View Post
    Even when mouse tracking is disabled? That seems like a huge overhead - surely only the item under the cursor is the only one which must be redrawn, not the entire table.
    Hi,
    How do I disable mouse tracking on the table?
    Best regards


    Added after 14 minutes:


    Hi,
    I have cell highlighting disabled.
    tableView->setSelectionMode(QAbstractItemView::NoSelection );

    Even so when the cursor is over a cell, the rowCount () function is activated, which is what I want to avoid. And when I press with the mouse the cell activates the data () function that I also want to avoid. On the other hand I just redraw the pressed cell.

    best regards
    Last edited by Eduardo Huerta; 5th December 2019 at 20:04.

  7. #7
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    459
    Thanked 63 Times in 59 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Problem

    It has nothing to do with the selection, it's the hovered item.

    You can't disable this behavior except that you can use a style which doesn't do a styling for hovered items. Apart from this I don't see why this should be disabled at all.

Similar Threads

  1. Replies: 2
    Last Post: 9th December 2015, 02:07
  2. QTableView - CSS Problem
    By Sir Rogers in forum Qt Programming
    Replies: 0
    Last Post: 14th February 2011, 20:10
  3. Qtableview problem
    By kira411 in forum Qt Programming
    Replies: 0
    Last Post: 30th July 2010, 11:34
  4. Problem with QTableView
    By habeas_corpse in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 23:17
  5. Problem about QTableView.
    By fengtian.we in forum Qt Programming
    Replies: 1
    Last Post: 1st November 2007, 00:13

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.