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 to hide a page of tabview?
Forum Updated to NodeBB v4.3 + New Features

How to hide a page of tabview?

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 4 Posters 5.4k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #4

    tabBar()

    http://doc.qt.io/qt-5/qtabwidget.html#tabBar

    1 Reply Last reply
    2
    • VRoninV VRonin

      You could try tabWidget->tabBar()->tabButton(i)->hide() where i is the index of the tab

      MucipM Offline
      MucipM Offline
      Mucip
      wrote on last edited by
      #5

      Hi @VRonin ,
      When I use below code raise error and crashed!

      ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)->hide();

      When I remove "QTabBar::LeftSide" then compiler error comes up! And asking for the second input to the function. :(

      Regards,
      Mucip:)

      VRoninV 1 Reply Last reply
      0
      • MucipM Mucip

        Hi @VRonin ,
        When I use below code raise error and crashed!

        ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)->hide();

        When I remove "QTabBar::LeftSide" then compiler error comes up! And asking for the second input to the function. :(

        Regards,
        Mucip:)

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #6

        @Mucip said in How to hide a page of tabview?:

        raise error and crashed

        Could you post the stack trace?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • MucipM Offline
          MucipM Offline
          Mucip
          wrote on last edited by
          #7

          Hi,
          I hope I understood correct,
          0_1523950068658_Error.PNG
          1 QWidget::hide qwidget.cpp 8058 0x317270f
          2 MainWindow::on_pushButton_2_clicked mainwindow.cpp 50 0x401a20
          3 MainWindow::qt_static_metacall moc_mainwindow.cpp 76 0x401ac6
          4 MainWindow::qt_metacall moc_mainwindow.cpp 109 0x401bb8
          5 QMetaObject::metacall qmetaobject.cpp 301 0x6bb14231
          6 QMetaObject::activate qobject.cpp 3781 0x6bb3272b
          7 QMetaObject::activate qobject.cpp 3628 0x6bb32921
          8 QAbstractButton::clicked moc_qabstractbutton.cpp 308 0x3248afc
          9 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 414 0x3248d25
          10 QAbstractButtonPrivate::click qabstractbutton.cpp 407 0x324a4ca
          11 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1011 0x324a6fa
          12 QWidget::event qwidget.cpp 8817 0x318b046
          13 QAbstractButton::event qabstractbutton.cpp 968 0x324bb0c
          14 QPushButton::event qpushbutton.cpp 682 0x32dfc21
          15 QApplicationPrivate::notify_helper qapplication.cpp 3732 0x31486dc
          16 QApplication::notify qapplication.cpp 3208 0x3150252
          17 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1044 0x6bb0af83
          18 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 237 0x314f2f1
          19 QApplicationPrivate::sendMouseEvent qapplication.cpp 2709 0x314f2f1
          20 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 655 0x31a1aa3
          21 QWidgetWindow::event qwidgetwindow.cpp 273 0x31a3b99
          22 QApplicationPrivate::notify_helper qapplication.cpp 3732 0x31486dc
          23 QApplication::notify qapplication.cpp 3104 0x314fcd4
          24 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1044 0x6bb0af83
          25 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 237 0xd06a9f7
          26 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 1957 0xd06a9f7
          27 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1741 0xd06c229
          28 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 976 0xd04ce5d
          29 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 82 0x62ababb4
          30 qt_internal_proc(HWND__ *, unsigned int, unsigned int, long) *16 qeventdispatcher_win.cpp 237 0x6bb5b9fd
          31 USER32!AddClipboardFormatListener 0x7703e0bb
          32 USER32!EndTask 0x77048849
          33 QEventDispatcherWin32Private::sendTimerEvent qeventdispatcher_win.cpp 456 0x6bb5b439
          34 ?? 0x550e72
          35 USER32!EndTask 0x7704b145
          36 ?? 0x401
          37 ??

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #8

            Could you check if ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide) returns null?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            MucipM 1 Reply Last reply
            0
            • VRoninV VRonin

              Could you check if ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide) returns null?

              MucipM Offline
              MucipM Offline
              Mucip
              wrote on last edited by
              #9

              Dear @VRonin,
              How???

              Regards,
              Mucip:)

              VRoninV 1 Reply Last reply
              0
              • MucipM Mucip

                Dear @VRonin,
                How???

                Regards,
                Mucip:)

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #10

                @Mucip said in How to hide a page of tabview?:

                How???

                if(ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)==nullptr)
                qDebug("It's NULL!");
                

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                MucipM 1 Reply Last reply
                0
                • VRoninV VRonin

                  @Mucip said in How to hide a page of tabview?:

                  How???

                  if(ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)==nullptr)
                  qDebug("It's NULL!");
                  
                  MucipM Offline
                  MucipM Offline
                  Mucip
                  wrote on last edited by
                  #11

                  Dear @VRonin ,
                  Yes. It returns NULL... ?!

                  Regards,
                  Mucip:)

                  1 Reply Last reply
                  0
                  • J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #12

                    to quote Chris-Kawa from this thread 5 years ago:

                    @Chris-Kawa said in [Solved] Hiding tab from QTabWidget made in QtCreator:

                    There's no built in method like setTabVisible(false) unfortunately.
                    The workaround I often use is applying this stylesheet:
                    @
                    QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }
                    @
                    and then using setTabEnabled(false).
                    Of course if you also need disabled (grayed out) tabs this method won't work.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    MucipM 1 Reply Last reply
                    1
                    • J.HilkJ J.Hilk

                      to quote Chris-Kawa from this thread 5 years ago:

                      @Chris-Kawa said in [Solved] Hiding tab from QTabWidget made in QtCreator:

                      There's no built in method like setTabVisible(false) unfortunately.
                      The workaround I often use is applying this stylesheet:
                      @
                      QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }
                      @
                      and then using setTabEnabled(false).
                      Of course if you also need disabled (grayed out) tabs this method won't work.

                      MucipM Offline
                      MucipM Offline
                      Mucip
                      wrote on last edited by Mucip
                      #13

                      Dear @J.Hilk ,
                      I have seen this before but ıt must be easier way I guess...
                      I tryed styleshit but I do not know much about stylsheet?!...
                      Regards,
                      Mucip:)

                      J.HilkJ 1 Reply Last reply
                      0
                      • MucipM Mucip

                        Dear @J.Hilk ,
                        I have seen this before but ıt must be easier way I guess...
                        I tryed styleshit but I do not know much about stylsheet?!...
                        Regards,
                        Mucip:)

                        J.HilkJ Offline
                        J.HilkJ Offline
                        J.Hilk
                        Moderators
                        wrote on last edited by J.Hilk
                        #14

                        @Mucip
                        well it should be pretty simple and kind of self-explanatory

                        tabWidget->setStyleSheet("QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }"); //This needs to be done once, preverably in your constructor or inside QtDesigner, should you use it
                        
                        //On hide Tab_0 clicked
                        tabWidget->setTabEnabled(0, false);
                        

                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        MucipM 1 Reply Last reply
                        1
                        • J.HilkJ J.Hilk

                          @Mucip
                          well it should be pretty simple and kind of self-explanatory

                          tabWidget->setStyleSheet("QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }"); //This needs to be done once, preverably in your constructor or inside QtDesigner, should you use it
                          
                          //On hide Tab_0 clicked
                          tabWidget->setTabEnabled(0, false);
                          
                          MucipM Offline
                          MucipM Offline
                          Mucip
                          wrote on last edited by
                          #15

                          Dear @J.Hilk ,
                          Yes. It worked... :)
                          But the tab label is still visible?!...

                          Regards,
                          Mucip:)

                          J.HilkJ 1 Reply Last reply
                          0
                          • MucipM Mucip

                            Dear @J.Hilk ,
                            Yes. It worked... :)
                            But the tab label is still visible?!...

                            Regards,
                            Mucip:)

                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by
                            #16

                            @Mucip
                            I'm not sure what you mean exactly

                            but you can take a look here:
                            http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

                            what else you can do with the QTabWidget and QStyleSheet


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            MucipM 1 Reply Last reply
                            0
                            • J.HilkJ J.Hilk

                              @Mucip
                              I'm not sure what you mean exactly

                              but you can take a look here:
                              http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

                              what else you can do with the QTabWidget and QStyleSheet

                              MucipM Offline
                              MucipM Offline
                              Mucip
                              wrote on last edited by
                              #17

                              Dear @J.Hilk ,
                              You may check:
                              Before Hide status:
                              0_1523957969434_BeforeHide.PNG

                              After Hide Status:
                              0_1523957985802_AfterHide.PNG

                              Yes. It's disabeld but tab labels are still visible?!... :(

                              Regards,
                              Mucip:)

                              J.HilkJ 1 Reply Last reply
                              0
                              • MucipM Mucip

                                Dear @J.Hilk ,
                                You may check:
                                Before Hide status:
                                0_1523957969434_BeforeHide.PNG

                                After Hide Status:
                                0_1523957985802_AfterHide.PNG

                                Yes. It's disabeld but tab labels are still visible?!... :(

                                Regards,
                                Mucip:)

                                J.HilkJ Offline
                                J.HilkJ Offline
                                J.Hilk
                                Moderators
                                wrote on last edited by
                                #18

                                @Mucip
                                sry, 5 years i s a long time, stuff changes.

                                The stylesheet is supposed to be QTabBar not QTabWidget

                                tabWidget->setStyleSheet("QTabBar::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }");
                                

                                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                Q: What's that?
                                A: It's blue light.
                                Q: What does it do?
                                A: It turns blue.

                                MucipM 1 Reply Last reply
                                1
                                • J.HilkJ J.Hilk

                                  @Mucip
                                  sry, 5 years i s a long time, stuff changes.

                                  The stylesheet is supposed to be QTabBar not QTabWidget

                                  tabWidget->setStyleSheet("QTabBar::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }");
                                  
                                  MucipM Offline
                                  MucipM Offline
                                  Mucip
                                  wrote on last edited by
                                  #19

                                  Dear @J.Hilk ,
                                  Yes thanks. But something happening strange! I do not know why? Very little part of the picture (picture labels of first tab which is just hided!) remain back. Whan I click other tabs than it disappears... ?!
                                  Strange?!...
                                  0_1523962521694_hata.PNG

                                  Regards,
                                  Mucip:)

                                  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