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. Catch TabWidget in active subwindows
Qt 6.11 is out! See what's new in the release blog

Catch TabWidget in active subwindows

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 532 Views 1 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.
  • F Offline
    F Offline
    f.lerdino
    wrote on last edited by
    #1

    I want to catch a qtabwidget in a subactivewindows but the problem is that when I use activeSubWindow().widget I don't have setcurrentindex in order to set one tab active(setfont).
    what's the problem?

    /*QMdiArea container*/
    test = new QMdiArea;
    setCentralWidget(test);
    

    stat2 = new QMdiSubWindow;
    test->addSubWindow(stat2);
    stat2->setWindowTitle(tr("stat2"));
    test->subWindowActivated(stat2);

        /********TESTTTTTTT**********/
        onglets2 = new QTabWidget();
        onglets2->setGeometry(30, 20, 240, 160);
    
        // 2 : Créer les pages, en utilisant un widget parent pour contenir chacune des pages
        QWidget *page10 = new QWidget;
        QWidget *page20 = new QWidget;
        QLabel *page30 = new QLabel; // Comme un QLabel est aussi un QWidget (il en hérite), on peut aussi s'en servir de page
        onglets2->addTab(page10, "Graphe Traffic IPv4");
        onglets2->addTab(page20, "Stats");
        onglets2->addTab(page30, "Info-app");
        stat2->setWidget(onglets2);
    

    void MainWindow::toTab1()
    {
    /catch active ongles(QtabWidget) and set Index to 1/
    onglets2 = test->activeSubWindow(). ----> setcurrentindex<---- ???
    }

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

      Hi
      You will need to cast it to the right type since it returns the base class (Qwidget)
      QTabWidget * tn = qobject_cast<QTabWidget *>( test->activeSubWindow()->widget())
      if (tn) { // this check is critical. the cast can fail if not a tabwidget
      use it
      }

      1 Reply Last reply
      1

      • Login

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