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. QTableView Vs QTableWidget creating a table
Forum Update on Monday, May 27th 2025

QTableView Vs QTableWidget creating a table

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 430 Views
  • 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.
  • S Offline
    S Offline
    Swati777999
    wrote on 2 Dec 2021, 03:10 last edited by Swati777999 12 Feb 2021, 03:34
    #1

    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/1

    I 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!

    “ In order to be irreplaceable, one must always be different” – Coco Chanel

    S 1 Reply Last reply 2 Dec 2021, 07:01
    0
    • S Swati777999
      2 Dec 2021, 03:10

      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/1

      I 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!

      S Online
      S Online
      sierdzio
      Moderators
      wrote on 2 Dec 2021, 07:01 last edited by
      #2

      @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.

      (Z(:^

      S 1 Reply Last reply 2 Dec 2021, 07:58
      2
      • S sierdzio
        2 Dec 2021, 07:01

        @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.

        S Offline
        S Offline
        Swati777999
        wrote on 2 Dec 2021, 07:58 last edited by
        #3

        @sierdzio Thanks.

        “ In order to be irreplaceable, one must always be different” – Coco Chanel

        1 Reply Last reply
        0

        1/3

        2 Dec 2021, 03:10

        • Login

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