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 get usesScrollButtons buttons to scroll tabs when it has many tabs For MAC?

How to get usesScrollButtons buttons to scroll tabs when it has many tabs For MAC?

Scheduled Pinned Locked Moved Solved General and Desktop
qtabbarmacosqscrollbarqtabwidget
11 Posts 3 Posters 3.6k Views
  • 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
    SGaist
    Lifetime Qt Champion
    wrote on 13 Sept 2018, 21:34 last edited by
    #2

    Hi,

    What version of Qt are you using ?
    On what version of macOS ?

    Can you provide a minimal compilable example that shows that behaviour ?

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

    Y 1 Reply Last reply 13 Sept 2018, 22:16
    0
    • A Offline
      A Offline
      AndyS
      Moderators
      wrote on 13 Sept 2018, 21:39 last edited by
      #3

      I think that this is because the style does not support it, so if you are using the macOS style you won't get the buttons. Try running your application with -style fusion and then it should show up.

      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Y 1 Reply Last reply 13 Sept 2018, 22:22
      1
      • S SGaist
        13 Sept 2018, 21:34

        Hi,

        What version of Qt are you using ?
        On what version of macOS ?

        Can you provide a minimal compilable example that shows that behaviour ?

        Y Offline
        Y Offline
        Yash001
        wrote on 13 Sept 2018, 22:16 last edited by Yash001
        #4

        @SGaist Thank you for taking interest in my question.

        I am using Qt 5.11.0 and MacOS version is 10.13.5.

        Here I put separate function using QTabBar.

        QWidget* TestClass::getwidget(){
            static QWidget *w = 0;
            
            if (w) {
                return w;
            }
            
            w = new QWidget();
            
            auto *lay = (new QVBoxLayout(w));
            lay->setContentsMargins(0,0,0,0);
            lay->setSpacing(0);
            
            QPushButton *addNewButton = nullptr;
            QPushButton *tileButton = nullptr;
            
            QTabBar *tabBar = nullptr;
            
            
            QFrame *tabFrame = new QFrame();
            auto *tabFrameLay = new QHBoxLayout(tabFrame);
            tabFrameLay->setContentsMargins(0,0,0,0);
            tabFrameLay->setSpacing(0);
            
            tabFrameLay->addWidget(tabBar = new QTabBar);
            tabFrameLay->addWidget(addNewButton = new QPushButton("+"));
            tabFrameLay->addStretch(1);
            tabFrameLay->addWidget(tileButton = new QPushButton("View All Graphs"));
            lay->addWidget(tabFrame);
            
            tabBar->setExpanding(false);
            tabBar->setMovable(true);
            //tabBar->setUsesScrollButtons(true);
            
            static int tabIndex = 0;
            QObject::connect(addNewButton, &QPushButton::clicked, [=]() {
                tabBar->insertTab(tabIndex, "---------------TabName----123456789");
                tabBar->setCurrentIndex(tabIndex);
                tabIndex++;
            });
            
            return w;
        }
        

        Pic from windows
        0_1536877801508_9dc39185-701b-41c0-8553-04fc8568bf30-image.png

        pic from MAC
        0_1536877944601_70dc5d51-7e1a-4d60-b456-5e383a297102-image.png

        1 Reply Last reply
        0
        • A AndyS
          13 Sept 2018, 21:39

          I think that this is because the style does not support it, so if you are using the macOS style you won't get the buttons. Try running your application with -style fusion and then it should show up.

          Y Offline
          Y Offline
          Yash001
          wrote on 13 Sept 2018, 22:22 last edited by
          #5

          @AndyS Thank you for direction. I am sorry, May be it is silly question. But I don't about -style fusion. What is -style fusion? How can I use it?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AndyS
            Moderators
            wrote on 13 Sept 2018, 22:23 last edited by
            #6

            @Yash001 I suggest you have a look at http://doc.qt.io/qt-5/qstyle.html as this will give more details. But the quick version is to just start your application with the "-style fusion" arguments.

            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Y 1 Reply Last reply 13 Sept 2018, 22:28
            1
            • A AndyS
              13 Sept 2018, 22:23

              @Yash001 I suggest you have a look at http://doc.qt.io/qt-5/qstyle.html as this will give more details. But the quick version is to just start your application with the "-style fusion" arguments.

              Y Offline
              Y Offline
              Yash001
              wrote on 13 Sept 2018, 22:28 last edited by Yash001
              #7

              @AndyS Thank you I will go in more detail.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                Yash001
                wrote on 14 Sept 2018, 23:32 last edited by Yash001
                #8

                Hi @AndyS,

                I am still stuck in same issue, as per your guideline, and from reading documents.

                The style of the entire application can be set using the QApplication::setStyle() function. It can also be specified by the user of the application, using the -style command-line option:

                I create my own style for QToolButton with help GUI.css file, and I applied to application with help of ApplyStyle() function.

                I am calling ApplyStyle() function is from constructor.

                ApplyStyle() function definition.

                void MainWindow::ApplyStyle() {
                
                    QFile f("./GUI.css");
                
                    if(!f.open(QIODevice::ReadOnly))
                        return;
                
                   QString newStyleSheet = f.readAll();
                	
                    qobject_cast<QApplication *>(QApplication::instance())->setStyleSheet(newStyleSheet);
                
                    f.close();
                }
                

                GUI.css file.

                QTabBar QToolButton { /* the scroll buttons are tool buttons */
                    background:light yellow;
                }
                
                QTabBar QToolButton::right-arrow { /* the arrow mark in the tool buttons */
                border:5px solid red;
                }
                
                QTabBar QToolButton::left-arrow {
                border:5px solid green;
                }
                

                Still Mac System does not recognized the usesScrollButtons.

                I checked ```tabbar->usesScrollButtons();``, and It is return false on Mac.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 16 Sept 2018, 21:16 last edited by
                  #9

                  That's because the macOS style doesn't implement them. As stated in the QTabBar documentation: By default the value is style dependant.. It's not a bug it's a platform guideline. Just check with Safari, open lots of tabs. You won't see any scroll button.

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

                  Y 1 Reply Last reply 17 Sept 2018, 17:10
                  1
                  • S SGaist
                    16 Sept 2018, 21:16

                    That's because the macOS style doesn't implement them. As stated in the QTabBar documentation: By default the value is style dependant.. It's not a bug it's a platform guideline. Just check with Safari, open lots of tabs. You won't see any scroll button.

                    Y Offline
                    Y Offline
                    Yash001
                    wrote on 17 Sept 2018, 17:10 last edited by
                    #10

                    @SGaist got it.

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      Yash001
                      wrote on 18 Sept 2018, 19:37 last edited by
                      #11

                      Thank You @SGaist and @AndyS. I am able to get QToolButton of QTabBar by applying Fusion style.

                      I applied Fusion Style By:

                      #include "mainwindow.h"
                      
                      #include <QTimer>
                      #include <QtGlobal>
                      
                      
                      #include <QFile>
                      
                      
                      #include <QLocale>
                      #include <QSplashScreen>
                      #include <QGuiApplication>
                      #include <qstylefactory.h>
                      
                      
                      int main(int argc, char *argv[]) {
                          QLocale::setDefault(QLocale::system());
                      
                          QApplication a(argc, argv);
                          a.setStyle(QStyleFactory::create("Fusion"));
                          
                          MainWindow w;
                          w.showMaximized();
                          return a.exec();
                      }
                      
                      1 Reply Last reply
                      0

                      11/11

                      18 Sept 2018, 19:37

                      • Login

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