Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to read null value from QTableWidget?
Forum Updated to NodeBB v4.3 + New Features

How to read null value from QTableWidget?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aurora
    wrote on last edited by
    #1

    In my QTableWidget, there exist some cells whose values are Null(it contains nothing)
    But when i'm trying to read table widget, if it encounters null cell, program crashes...
    How can i get rid of this problem?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxim.prishchepa
      wrote on last edited by
      #2

      if item at cell is null - then at cell - is nothing ;)

      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aurora
        wrote on last edited by
        #3

        Such cells present in between, because of such null cells i'm unable to do any operation on that table....

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          @
          QTableWidgetItem *item = tableWidget->item(5, 7);
          if(item) {
          // the item exists
          // do something with it
          // it is safe to call
          QString t = item->text();
          } else {
          // the item does NOT exist
          // you have a NULL pointer here
          // NEVER call item->xxx here, the program will crash
          // you may call this a NULL item
          // if you want to do something here, create an item
          // and put it into the table widget
          }
          @

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved