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. Move values from Qtablewidget to TextEdit
Qt 6.11 is out! See what's new in the release blog

Move values from Qtablewidget to TextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 528 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 iSimstix1
    #1

    Hi!
    I have a loop with a two-dimensional array that outputs values to Qtablewidget (a table is obtained). How do I display these values in TextEdit, for example, separated by commas?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      In your loop concatenate the values in a string putting the comma and line returns at the right place and then set that string on your QTextEdit.

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

      I 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        In your loop concatenate the values in a string putting the comma and line returns at the right place and then set that string on your QTextEdit.

        I Offline
        I Offline
        iSimstix1
        wrote on last edited by
        #3

        @SGaist said in Move values from Qtablewidget to TextEdit:

        Hi,

        In your loop concatenate the values in a string putting the comma and line returns at the right place and then set that string on your QTextEdit.

        @SGaist Can you tell me a little more? Please
        Where and how exactly do I need to convert a value to a string?

        int count = 1;
            for (int i = 0; i < ui->tableWidget->rowCount(); i++) {
                for (int j = 0; j < ui->tableWidget->columnCount(); j++) {
        
        
                    QTableWidgetItem *itm = new QTableWidgetItem(tr("%1").arg((my_rand(1))));
        
                    ui->tableWidget->setItem(i, j, itm);
                    count++;
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You are already creating strings to put in your QTableWidgetItem, use that string and append it to a variable that you declared outside your loops.

          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
          0

          • Login

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