Results 1 to 3 of 3

Thread: QTableWidget test if the cell or item are empty

  1. #1
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidget test if the cell or item are empty

    Hi!
    I using Qt version 4.3.2.
    How I make to test if the fields (cell or item) of QTableWidget are empty?
    I made the test thus: testing row =0; and column = 0;

    Qt Code:
    1. tableWidget = new QTableWidget(this);
    2. tableWidget->setRowCount(3);
    3. tableWidget->setColumnCount(3);
    4.  
    5. if (tableWidget->item(0,0)->text().isEmpty())
    6. {
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 

    but without success.
    Last edited by jpn; 31st December 2007 at 05:34. Reason: missing [code] tags

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

    Default Re: QTableWidget test if the cell or item are empty

    There are no items in cells until one sets them with QTableWidget::setItem() or after user has edited them.

    Qt Code:
    1. QTableWidgetItem* item = tableWidget->item(0,0);
    2. if (!item || item->text().isEmpty())
    3. {
    4. ...
    5. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    jaca (2nd January 2008), milli (4th May 2011)

  4. #3
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget test if the cell or item are empty


    it functioned very well
    Thanks very much.

Similar Threads

  1. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57
  2. QTableWidget item checkable and combo?
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2006, 07:12

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.