Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to display the values that I get on column of the table widget
Forum Updated to NodeBB v4.3 + New Features

How to display the values that I get on column of the table widget

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 1.6k 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.
  • R Offline
    R Offline
    reem9611
    wrote on last edited by
    #1

    Hi
    I get values output from a function and I can display that on a text browser
    Now I would like to know how to display that values in first column of the table.

    Actually I can creat the table widget .the only thing remain is how to display outputs in the table

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      Hello and welcome to devnet,

      you have to basically call the name of the role in your delegate, otherwise it would also work if you call the data function of your model and pass the DisplayRole and index as parameters.

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

        Here's a very small sample how to put the content of a tableview's cell into a lineedit:

        lineEdit1->setText(model->data(model->index(ui->tableView->currentIndex().row(), column)).toString());

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onek24
          wrote on last edited by
          #4

          [quote author="clochydd" date="1394200332"]Here's a very small sample how to put the content of a tableview's cell into a lineedit:

          lineEdit1->setText(model->data(model->index(ui->tableView->currentIndex().row(), column)).toString());[/quote]

          I'm sure he meant the QML-TableView since this is the QtQuick-Subforum, but it should work in the QML-TableView, too, at least the idea should.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            reem9611
            wrote on last edited by
            #5

            [quote author="onek24" date="1394198514"]Hello and welcome to devnet,

            you have to basically call the name of the role in your delegate, otherwise it would also work if you call the data function of your model and pass the DisplayRole and index as parameters.[/quote]

            i tried to create table widget in mainwindow and it show in my app
            QTableWidgetItem *xHeaderItem = new QTableWidgetItem(tr("x"));//Set header label
            ui->tableWidget->setHorizontalHeaderItem(0, xHeaderItem);
            xHeaderItem->setTextAlignment(Qt::AlignCenter);

            then I need to show my result which is done when the user click run button:
            i can show my result on text browser by using the following line:
            ui->textBrowser->setText(QString("%1").arg(result_x));

            now i need to show the result in table widget and my result is group of calculated numbers that should be display in the column 1 of the table widget. please can you give any example that may help me to understand how to set values in the table widget

            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