Results 1 to 5 of 5

Thread: Blank rows after populating a QTableWidget

  1. #1
    Join Date
    Dec 2014
    Posts
    11
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Blank rows after populating a QTableWidget

    Hi!

    Sometimes I get blank rows at end of the QTableWidget after populating data. Look how it looks like:

    blankrow1.png

    Just after sorting table (clicking over header) the blank rows simply disappear:

    blankrow2.png

    What could be going on here? I double checked to confirm that I'm not setting wrong values with setRowCount(). Here is the code.

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Blank rows after populating a QTableWidget

    Dynamic sorting can get confused when adding new records (see note in QSortFilterProxyModel) Try disabling sorting while you add.

  3. #3
    Join Date
    Dec 2014
    Posts
    11
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Blank rows after populating a QTableWidget

    This is a QTableWidget, it is populated manually, not using models. I'm trying other things here, if I have any success I will post here.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Blank rows after populating a QTableWidget

    QTableWidget is a QTableView that maintains a model internally for your convenience. The sorting functionality is inherited directly from QTableView and operates on the underlying model Did you actually try disabling sorting?

  5. #5
    Join Date
    Dec 2014
    Posts
    11
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Blank rows after populating a QTableWidget

    Well... It's an intermittent problem, I have to insist on table generation a few times in order to see it happening. I tried using the following:

    Qt Code:
    1. ui->tableWidget->setSortingEnabled(false);
    2.  
    3. //add data
    4.  
    5. ui->tableWidget->setSortingEnabled(true);
    To copy to clipboard, switch view to plain text mode 

    I'm not sure if this method changes the dynamicSortFilter parameter in QSortFilterProxyModel. After a few tries the problem happened again, but now the application also crashes when I close the window after observing the blank rows. When I don't see the blank rows it closes without any issue.

    I'm populating this table in two steps. In the first step I have the data to fill only one column, but I'm still creating all the empty QTableWidgetItems for the whole table. In the second step I'm only updating the remaining QTableWidgetItem with setText() or setData(). I'm disabling and enabling sorting before and after each step.

    I'm suspecting that the problem is not with the data model, but while drawing the table graphics. I'm saying this because I cannot select the blank rows and after sorting they simply vanish.


    Added after 4 minutes:


    The only other weird thing I'm seeing in this QTableWidget happens when I call 'QTableWidget->setItem()' at the first time and then I receive the following errors in application output:

    QObject::connect: Cannot queue arguments of type 'QVector<int>'
    (Make sure 'QVector<int>' is registered using qRegisterMetaType().)
    QObject::connect: Cannot queue arguments of type 'QVector<int>'
    (Make sure 'QVector<int>' is registered using qRegisterMetaType().)
    QObject::connect: Cannot queue arguments of type 'QVector<int>'
    (Make sure 'QVector<int>' is registered using qRegisterMetaType().)
    QObject::connect: Cannot queue arguments of type 'QVector<int>'
    (Make sure 'QVector<int>' is registered using qRegisterMetaType().)
    QObject::connect: Cannot queue arguments of type 'QVector<int>'
    (Make sure 'QVector<int>' is registered using qRegisterMetaType().)

    I don't how it could be related, maybe a coincidence, but I'm setting a QString:

    Qt Code:
    1. QString nextSufix = nextVariable.OID.right(nextVariable.OID.size() - this->OIDs.first().size());
    2.  
    3. //add hidden column for index/sufix
    4. ui->tableWidget->setItem(row, 0, new QTableWidgetItem(nextSufix));
    To copy to clipboard, switch view to plain text mode 
    Last edited by RenatoFerreira; 22nd November 2015 at 09:02.

Similar Threads

  1. Replies: 2
    Last Post: 28th July 2014, 12:46
  2. QTableView showing blank rows
    By rawfool in forum Newbie
    Replies: 3
    Last Post: 8th May 2014, 01:17
  3. Populating qtablewidget with QStringlist
    By decipher in forum Newbie
    Replies: 1
    Last Post: 31st August 2012, 08:25
  4. Populating a QtableWidget using a list of custom widgets
    By gerocampo in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2010, 10:28
  5. customize QTableView to add blank rows
    By rosenth in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2010, 11:47

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.