QTableView Vs QTableWidget creating a table
-
Hi All,
Refer to the following Q for the complete background.
https://forum.qt.io/topic/132460/finding-similar-functions-of-qtablewidget-as-that-of-qtableview/1I want to draw a table inside a widget.
I have achieved that with QTableWidget object with setRowCount and setColumnCount . Is this operation possible with any function of QTableView?if I use
QWidget *myWidget = new QWidget();
QGridLayout *tableLayout = new QGridLayout();
QTableView *first_table=new QTableWidget();
tableLayout->addWidget(first_table,0,0);
first_table->setSpan(7,2,10,20);myWidget->setLayout(tableLayout);
QMainWindow::setCentralWidget(myWidget);setSpan doesn't seem to produce anything. Can someone tell me why?
Thanks!
-
Hi All,
Refer to the following Q for the complete background.
https://forum.qt.io/topic/132460/finding-similar-functions-of-qtablewidget-as-that-of-qtableview/1I want to draw a table inside a widget.
I have achieved that with QTableWidget object with setRowCount and setColumnCount . Is this operation possible with any function of QTableView?if I use
QWidget *myWidget = new QWidget();
QGridLayout *tableLayout = new QGridLayout();
QTableView *first_table=new QTableWidget();
tableLayout->addWidget(first_table,0,0);
first_table->setSpan(7,2,10,20);myWidget->setLayout(tableLayout);
QMainWindow::setCentralWidget(myWidget);setSpan doesn't seem to produce anything. Can someone tell me why?
Thanks!
@Swati777999 said in QTableView Vs QTableWidget creating a table:
I have achieved that with QTableWidget object with setRowCount and setColumnCount . Is this operation possible with any function of QTableView?
Yes, but you need a model (a subclass of QAbstractItemModel, for example). The view will use it to populate itself with delegates.
-
@Swati777999 said in QTableView Vs QTableWidget creating a table:
I have achieved that with QTableWidget object with setRowCount and setColumnCount . Is this operation possible with any function of QTableView?
Yes, but you need a model (a subclass of QAbstractItemModel, for example). The view will use it to populate itself with delegates.
@sierdzio Thanks.