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. Load QTableWidgetItem from file
Forum Updated to NodeBB v4.3 + New Features

Load QTableWidgetItem from file

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 852 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.
  • C Offline
    C Offline
    conflictEnsues
    wrote on last edited by
    #1

    I have saved ui->tableWidgetName->verticalHeader() to a text file. In the file it appears like this: 0x1ef54c8.
    I load the hex from the file to a QString (var) but do not know how to convert it to a QTableWidgetItem for setting the header on the table when the program is re-opened.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      Writing and loading from files (or any other QIODevice) should be done the same way. So writing with the QString << operator will result in a QString >> operator reading.
      When you have the QString, simply set the text of the QTableWidgetItem with
      @
      ui->tableWidgetName->VerticalHeaderItem(<<your column>>)->setText(<<your string>>);
      @

      Greetz, Jeroen

      1 Reply Last reply
      0
      • C Offline
        C Offline
        conflictEnsues
        wrote on last edited by
        #3

        That would work for setting a single header; but I am trying to set them all at once using the entire verticalHeader, i.e., the name of row1, name of row2, name of row3.... If I must make a for loop and do it in the method you stated I shall; will do so now as a temporary solution; but would prefer to use functions already available if they exist.

        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