Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-58266

Ugly tabs on macOS

    XMLWordPrintable

Details

    • macOS

    Description

      Hello! For some reason QTabWidget on macOS looks non-native when the document mode is active. The first image shows QTabWidget with ugly tabs, while the second - the standard Terminal app that has standard tabs.

      The problem is that setDocumentMode(true) call makes the QTabWidget to enable the so-called document mode, when each tab contains an independent document. For some reason, Qt does not use the standard style for it.

      Here is a code sample that reproduces the issue:
      File MainWindow.h:

      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      
      #include <QMainWindow>
      #include <QTabWidget>
      
      
      namespace Ui {
      class MainWindow;
      }
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
      private:
          Ui::MainWindow *ui;
      
          QTabWidget *tabs;
      };
      
      #endif // MAINWINDOW_H
      
      

      File MainWindow.cpp:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QPlainTextEdit>
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          tabs = new QTabWidget(this);
          setCentralWidget(tabs);
      
          tabs->setDocumentMode(true);
      
          for (auto i = 0; i < 3; ++i) {
              auto editor = new QPlainTextEdit();
              tabs->addTab(editor, "Editor");
          }
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      

      Any other file (main.cpp, form itself) is left untouched.

      I do not use any additional styles, everything is out-of-the-box&

      Attachments

        1. 2017_01_15_23_32_39.png
          2017_01_15_23_32_39.png
          32 kB
        2. 2017_01_15_23_43_53.png
          2017_01_15_23_43_53.png
          30 kB
        3. TabBarTestApp.zip
          2 kB
        For Gerrit Dashboard: QTBUG-58266
        # Subject Branch Project Status CR V

        Activity

          People

            wearyinside Oleg Yadrov
            xanx Ivan
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes