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. How programically order tabs in QTabWidget?
Qt 6.11 is out! See what's new in the release blog

How programically order tabs in QTabWidget?

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

    I try

    void TabWindow::keyReleaseEvent(QKeyEvent *event)
    {
        if (event->key()==Qt::Key_Control)
        {
            std::cout <<  "release" << std::endl;
            CodeEditor *current = qobject_cast<CodeEditor *>(tabWidget->currentWidget());
            tabWidget->removeTab(tabWidget->currentIndex());
            tabWidget->insertTab(0, current, current->name);
            tabWidget->setCurrentWidget(current);
        }
    }
    

    But is probably bad, because:

    void QLayout::removeWidget(QWidget *widget)
    {
        int i = 0;
        QLayoutItem *child;
        while ((child = itemAt(i))) {
            if (child->widget() == widget) {
                delete takeAt(i);
                invalidate();
            } else {
                ++i;
            }
        }
    }
    

    It is impossible change order of tabs?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AndrzejB
      wrote on last edited by
      #2

      But in Qt Creator is this solved - Tab when Control is pressed show list

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

        Hi
        From code you could use
        https://doc.qt.io/qt-5/qtabbar.html#moveTab
        via
        tabwidget->tabBar()

        1 Reply Last reply
        2

        • Login

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