Results 1 to 8 of 8

Thread: Problem with new QTableWidgetItem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with new QTableWidgetItem

    you may have to format it more like this so that you can access the item later.

    Qt Code:
    1. ui.table->setItem( row , 0, new QTableWidgetItem() );
    2. ui.table->item(row , 0 )->setText(QString( "%1" ).arg( num ) );
    3. ui.table->item(row, 0 )->setBackgroundColor( QColor(178,34,34) );
    To copy to clipboard, switch view to plain text mode 

    Something I found out after hours of invalid pointer access

  2. #2
    Join Date
    Sep 2009
    Posts
    31
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with new QTableWidgetItem

    Perfect.
    That's what I needed.

    Thanks.

  3. #3
    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: Problem with new QTableWidgetItem

    Where do you allocate space to hold the array of QTableWidgetItem pointers? If you never do that then this a recipe for serious crashing. Using a QList<QTableWidgetItem*> or QVector<QTableWidgetItem*> is a far safer option.

  4. #4
    Join Date
    Jul 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with new QTableWidgetItem

    Chris was that to me?

    They get held into the QTableWidget, I just reference them in the row and col of the table ( item( row, col) ), for my application they work fine, no issues, and no risk. They only get replaced when i say so.

  5. #5
    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: Problem with new QTableWidgetItem

    No, it was for the OP.

Similar Threads

  1. QTableWidgetItem
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 11th August 2011, 06:35
  2. QTableWidgetItem
    By weixj2003ld in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2011, 07:59
  3. QTableWidgetItem editing problem
    By fmariusd in forum Qt Programming
    Replies: 8
    Last Post: 4th September 2009, 08:10
  4. Problem with QTableWidgetItem
    By arunvv in forum Newbie
    Replies: 2
    Last Post: 9th May 2008, 00:04
  5. Replies: 3
    Last Post: 11th August 2007, 10:00

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.