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. QTabWidget setStyleSheet of background-color; QT5.12 Linux
Forum Updated to NodeBB v4.3 + New Features

QTabWidget setStyleSheet of background-color; QT5.12 Linux

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 212 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.
  • S Offline
    S Offline
    sanqi
    wrote on last edited by
    #1
    void LogWidget::initStyle()
    {
        QString styleString = "QTabWidget {"
                              " background-color: #302c3a4a;"
                              " color: #ffffff;"
                              "};"
                              "QTabWidget QPlainTextEdit {"
                              " background-color: transparent;"
                              " color: #ffffff;"
                              "}";
        setStyleSheet(styleString);
    }
    
    LogWidget::LogWidget(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::LogWidget)
    {
        ui->setupUi(this);
        initStyle();
    }
    

    I am facing issues with the tab switching being stuck. I find the background color of QTabWidget will change from default black to #302c3a4a if I call this function when switch tabs. How to set the background color of the QTabWidget always be #302c3a4a ?

    Pl45m4P 1 Reply Last reply
    0
    • S sanqi
      void LogWidget::initStyle()
      {
          QString styleString = "QTabWidget {"
                                " background-color: #302c3a4a;"
                                " color: #ffffff;"
                                "};"
                                "QTabWidget QPlainTextEdit {"
                                " background-color: transparent;"
                                " color: #ffffff;"
                                "}";
          setStyleSheet(styleString);
      }
      
      LogWidget::LogWidget(QWidget *parent) :
          QWidget(parent),
          ui(new Ui::LogWidget)
      {
          ui->setupUi(this);
          initStyle();
      }
      

      I am facing issues with the tab switching being stuck. I find the background color of QTabWidget will change from default black to #302c3a4a if I call this function when switch tabs. How to set the background color of the QTabWidget always be #302c3a4a ?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @sanqi

      Here is an example of how to style QTabWidget

      • https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

      I think the background changes when you switch the tabs because you show a widget with doesnt have your background color.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      S 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @sanqi

        Here is an example of how to style QTabWidget

        • https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

        I think the background changes when you switch the tabs because you show a widget with doesnt have your background color.

        S Offline
        S Offline
        sanqi
        wrote on last edited by
        #3

        @Pl45m4
        Thank you for your reply.I found the cause through the vetting process. QTabWidget doesn't seem to support setting ARGB colors, as I had problems with #302c3a4a colors, but other colors like red or #ff0000 worked fine.

        1 Reply Last reply
        0
        • S sanqi has marked this topic as solved on

        • Login

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