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. get and set qtablewidget parameters from a custom widget

get and set qtablewidget parameters from a custom widget

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 827 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.
  • R Offline
    R Offline
    rafael
    wrote on last edited by
    #1

    i have a qstackwidget with different custom widgets.
    in the new_tab page i have a widget that contains a qtablewidget.

    when i press the button i execute the code below.

    ui->new_tab->show();
    ui->menu_tab->hide();
    
    QTableWidget *tbl = ui->new_tab->findChild<QTableWidget*>("table_new");
    qDebug() << tbl;
    
    tbl->setHorizontalHeaderLabels(QStringList() << "Test Type" << "Depth" << "Date & Time");
    tbl->setColumnWidth(0,100);
    tbl->setColumnWidth(1,200);
    tbl->setColumnWidth(2,300);
    
    int currentRow = tbl->rowCount();
    tbl->setRowCount(currentRow+1);
    tbl->setItem(currentRow, 0, new QTableWidgetItem("lengh"));
    tbl->setItem(currentRow, 1, new QTableWidgetItem("width"));
    tbl->setItem(currentRow, 2, new QTableWidgetItem("height"));
    

    the code compiles fine but i don't see any data added to the qtablewidget.
    what am i missing?

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

      Hi,

      Aren't you missing a setColumnCount ?

      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
      • R Offline
        R Offline
        rafael
        wrote on last edited by
        #3

        i set that in the designer. i have a column count of 3.

        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