How to display the values that I get on column of the table widget
-
wrote on 7 Mar 2014, 13:18 last edited by
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
-
wrote on 7 Mar 2014, 13:21 last edited by
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.
-
wrote on 7 Mar 2014, 13:52 last edited by
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());
-
wrote on 7 Mar 2014, 15:10 last edited by
[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.
-
wrote on 9 Mar 2014, 07:14 last edited by
[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/5