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. Converting QTableWidgetItem
Qt 6.11 is out! See what's new in the release blog

Converting QTableWidgetItem

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 411 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.
  • I Offline
    I Offline
    iSimstix1
    wrote on last edited by
    #1

    Hi!
    I need to write the "itm" variable to TextEdit. How do I make the correct conversion?

    QTableWidgetItem *itm = new QTableWidgetItem(tr("%1").arg((my_rand(2))));
    ui->textEdit->setText(itm);
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You don't convert a QTabeWidgetItem, you extract its content: QTabeWidgetItem::text.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • I Offline
        I Offline
        iSimstix1
        wrote on last edited by
        #3

        Thanks, but it didn't work

        QTableWidgetItem *itm = new QTableWidgetItem(tr("%1").arg((my_rand(2))));
        ui->textEdit->setText(QTableWidgetItem::text(itm));
        
        jsulmJ 1 Reply Last reply
        0
        • I iSimstix1

          Thanks, but it didn't work

          QTableWidgetItem *itm = new QTableWidgetItem(tr("%1").arg((my_rand(2))));
          ui->textEdit->setText(QTableWidgetItem::text(itm));
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @iSimstix1 said in Converting QTableWidgetItem:

          ui->textEdit->setText(QTableWidgetItem::text(itm));

          Come on it is

          ui->textEdit->setText(itm->text());
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          3

          • Login

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