Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    get and set qtablewidget parameters from a custom widget

    General and Desktop
    2
    3
    723
    Loading More Posts
    • 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
      rafael last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • R
          rafael last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post