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. issue with nested qtabwidget with qvector<qtableview*> on the inner table
Forum Updated to NodeBB v4.3 + New Features

issue with nested qtabwidget with qvector<qtableview*> on the inner table

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 82 Views 2 Watching
  • 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
    swankster
    wrote last edited by
    #1

    I have an application with a nested QTabWidget. the outer Tab-A, and Tab-B select different types of tableViews. the inner QTabWidgets inside of Tab-A and Tab-B are dynamic in tab count which is why I am using QVector<QTableView*> within each inner tab.
    My functionality of selecting tabs on the inner QTabWidget works perfectly. my tableViews are all viewing as expected.

    When I switch the outer QTabWidget from Tab-A to Tab-b or visa-versa my application will crash.

    the below snippet is what creates my inner tabs. there is a duplicate function for Tab-B when it is called.

    QSqlTableModel *sourceModel = new QSqlTableModel( nullptr ); 
    sourceModel->setTable( "tablename" );
    QString filterString = "date = '" + date + "'";
    sourceModel->setFilter( filterString );
    sourceModel->select() ;
    CustomIdentityProxyModel *identityProxy = new CustomIdentityProxyModel();
    identityProxy->setSourceModel( sourceModel );
    QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel();
    proxyModel->setSourceModel( identityProxy );
    QTableView* tableView = new QTableView( this );
    tableView->setObjectName( date );
    tableView->setModel( proxyModel );
    tableView->setItemDelegate( m_customStyledItemDelegate );
    m_tableViewInner_ATabs.append( tableView );
    int tabIndex = ui->TabA_innerTab->addTab( tableView, date );
    ui->TabA_innerTab->setCurrentIndex( tabIndex );
    

    when switching outer tabs I recently added the follow snippet. before adding this snippet i got a "out of range" Not when switching it almost works. in that the tabs switch but are empty, and need to be re-selected to display the view. but when switching back again to the Tab-A it crashes on a segmentation fault.

    void MainWindow::on_tabWidget_tabBarClicked( int index )
    {
        switch ( index ) {
        case 0:
            for (int i = 0; i < m_tableViewInner_ATabs.size(); ++i) {
                QString tabName = m_tableViewInner_ATabs[i]->objectName();
                ui->TabA_innerTab->addTab( m_tableViewInner_ATabs[i], tabName );
            }
            break;
        case 1:
            for ( int i = 0; i < m_tableViewInner_BTabs.size(); ++i ) {
                QString tabName = m_tableViewInner_BTabs[i]->objectName();
                ui->TabB_innerTab->addTab( m_tableViewInner_BTabs[i], tabName );
            }
            break;
        }
    }
    

    I hope my situation is understandable and that one of the many brainiacs out their has some insight for me.
    thank you.

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

      Hi,

      To be sure I understand, each time you switch you add new tabs with the same name and the same widget ?
      Why not just build things once ?

      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
      • S Offline
        S Offline
        swankster
        wrote last edited by
        #3

        no, in order to get past the QVector[T] "out of range" and crash. I had to add to for loop to addTabs.

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

          Did you check with the debugger what was happening ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Did you check with the debugger what was happening ?

            S Offline
            S Offline
            swankster
            wrote last edited by
            #5

            @SGaist when I do not to the addTab i get
            ASSERT failure in QVector<T>::operator[]: "index out of range", file C:/msys64/mingw64/include/QtCore/qvector.h, line 462

            when I do addTab, I cant seem to determine where the segmentation fault occurs. indicating a highlight definition was not found.
            All syntax definitions are up to date.

            Not sure if this tells you anything?

            *running,thread-id="all"

            ~"[Thread 20288.0x4f48 exited with code 3221225725]\n"
            [Thread 20288.0x4f48 exited with code 3221225725]
            =thread-exited,id="2",group-id="i1"
            Thread 2 in group i1 exited.
            ~"[Thread 20288.0x4f44 exited with code 3221225725]\n"
            [Thread 20288.0x4f44 exited with code 3221225725]
            =thread-exited,id="1",group-id="i1"
            Thread 1 in group i1 exited.
            ~"[Thread 20288.0x4f4c exited with code 3221225725]\n"
            [Thread 20288.0x4f4c exited with code 3221225725]
            =thread-exited,id="3",group-id="i1"
            Thread 3 in group i1 exited.
            ~"[Thread 20288.0x4f74 exited with code 3221225725]\n"
            [Thread 20288.0x4f74 exited with code 3221225725]
            =thread-exited,id="4",group-id="i1"
            Thread 4 in group i1 exited.
            ~"[Thread 20288.0x4f78 exited with code 3221225725]\n"
            [Thread 20288.0x4f78 exited with code 3221225725]
            =thread-exited,id="5",group-id="i1"
            Thread 5 in group i1 exited.
            ~"[Thread 20288.0x4f7c exited with code 3221225725]\n"
            [Thread 20288.0x4f7c exited with code 3221225725]
            =thread-exited,id="6",group-id="i1"
            Thread 6 in group i1 exited.
            ~"[Thread 20288.0x4f80 exited with code 3221225725]\n"
            [Thread 20288.0x4f80 exited with code 3221225725]
            =thread-exited,id="7",group-id="i1"
            Thread 7 in group i1 exited.
            ~"[Thread 20288.0x4f88 exited with code 3221225725]\n"
            [Thread 20288.0x4f88 exited with code 3221225725]
            =thread-exited,id="9",group-id="i1"
            Thread 9 in group i1 exited.
            ~"[Thread 20288.0x4f8c exited with code 3221225725]\n"
            [Thread 20288.0x4f8c exited with code 3221225725]
            =thread-exited,id="10",group-id="i1"
            Thread 10 in group i1 exited.
            ~"[Thread 20288.0x4f90 exited with code 3221225725]\n"
            [Thread 20288.0x4f90 exited with code 3221225725]
            =thread-exited,id="11",group-id="i1"
            Thread 11 in group i1 exited.
            ~"[Thread 20288.0x4f94 exited with code 3221225725]\n"
            [Thread 20288.0x4f94 exited with code 3221225725]
            =thread-exited,id="12",group-id="i1"
            Thread 12 in group i1 exited.
            ~"[Thread 20288.0x4f84 exited with code 3221225725]\n"
            [Thread 20288.0x4f84 exited with code 3221225725]
            =thread-exited,id="8",group-id="i1"
            Thread 8 in group i1 exited.
            =thread-exited,id="13",group-id="i1"
            Thread 13 in group i1 exited.
            ~"\nProgram terminated with signal "
            ~"SIGSEGV, Segmentation fault.\n"

            1 Reply Last reply
            0
            • Axel SpoerlA Offline
              Axel SpoerlA Offline
              Axel Spoerl
              Moderators
              wrote last edited by
              #6

              As @SGaist said, can you run this in the debugger and inspect the call stack, when the crash happens?

              Software Engineer
              The Qt Company, Oslo

              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