Results 1 to 18 of 18

Thread: adding items in qtablewidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2006
    Posts
    72
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default adding items in qtablewidget

    Hi, I am having problems to show cells in my qtablewidget. These are parts of code that I use to implement qtablewidgetitems:


    tableTestSuits->setRowCount(0); // tableTestSuits is QTablewidget *

    for (unsigned j=0; j<vTestCaseResults.size();j++)
    {
    .......
    QTableWidgetItem *item=new QTableWidgetItem (tr(tempName.toLatin1()));
    QTableWidgetItem *item3=new QTableWidgetItem (tr(tempVersion.toLatin1()));
    QTableWidgetItem *item5=new QTableWidgetItem (tr(tempResult.toLatin1()));
    QTableWidgetItem *item2=new QTableWidgetItem (tr(tempDate.toLatin1()));
    QTableWidgetItem *item4=new QTableWidgetItem (tr(tempDuration.toLatin1()));
    tableTestSuits->insertRow(j);
    tableTestSuits->setItem(j,0,item2);
    tableTestSuits->setItem(j,3,item4);
    tableTestSuits->setItem(j,4,item5);
    tableTestSuits->setItem(j,1,item3);
    tableTestSuits->setItem(j,2,item);
    }

    I am pretty sure that strings for qtablewidgetitems are ok. So, there must be something else wrong, but I don't know what. Any suggestions welcomed.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: adding items in qtablewidget

    What value did you set the columnCount to?

  3. #3
    Join Date
    Nov 2006
    Posts
    72
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: adding items in qtablewidget

    I set it to 5

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: adding items in qtablewidget

    OK, do you see row and column labels on the table headers?

  5. #5
    Join Date
    Nov 2006
    Posts
    72
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: adding items in qtablewidget

    I see solumn headers, yes, but row headers no, because I've hide it with verticalHeader()->hide() method.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: adding items in qtablewidget

    Quote Originally Posted by Djony View Post
    I see solumn headers, yes, but row headers no, because I've hide it with verticalHeader()->hide() method.
    Can you see them, if you comment out that line?

  7. #7
    Join Date
    Nov 2006
    Posts
    72
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: adding items in qtablewidget

    yes, I can see them.

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

    Default Re: adding items in qtablewidget

    I'd still suspect the problem is with those strings. What happens if you replace:
    Qt Code:
    1. QTableWidgetItem *item=new QTableWidgetItem (tr(tempName.toLatin1()));
    To copy to clipboard, switch view to plain text mode 
    with something like
    Qt Code:
    To copy to clipboard, switch view to plain text mode 
    ?
    J-P Nurmi

  9. #9
    Join Date
    Nov 2006
    Posts
    72
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: adding items in qtablewidget

    I tried your stuff and it doesn't work, but found out very odd thing.

    When I replace j with zero (that means this code):

    tableTestSuits->insertRow(0);

    tableTestSuits->setItem(0,0,item2);
    tableTestSuits->setItem(0,3,item4);
    tableTestSuits->setItem(0,4,item5);
    tableTestSuits->setItem(0,1,item3);
    tableTestSuits->setItem(0,2,item);
    -----------------------------------------------

    I get cell properly. I found this very odd. Have any ideas about it?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: adding items in qtablewidget

    Quote Originally Posted by Djony View Post
    When I replace j with zero [...] I get cell properly. I found this very odd. Have any ideas about it?
    What is the value of "j" just before the insertRow() line?

  11. #11
    Join Date
    Nov 2006
    Posts
    72
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: adding items in qtablewidget

    j is parameter of for loop. Look my first post on this topic

Similar Threads

  1. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 13:20
  2. Limitation when adding more than 256 items to a model
    By darkadept in forum Qt Programming
    Replies: 5
    Last Post: 25th May 2006, 16:26
  3. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 21:04
  4. Adding tooltips to canvas items
    By jnana in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2006, 11:53
  5. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 20: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
  •  
Qt is a trademark of The Qt Company.