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. default background color of QTabWidget and QWidget/QGroupBox
QtWS25 Last Chance

default background color of QTabWidget and QWidget/QGroupBox

Scheduled Pinned Locked Moved Solved General and Desktop
qt4qtabwidgetqwidgetlayoutgroupbox
4 Posts 3 Posters 10.0k 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.
  • H Offline
    H Offline
    helloworld12345
    wrote on 11 Aug 2017, 00:41 last edited by helloworld12345 8 Nov 2017, 01:08
    #1

    When I use below code, the default background color is light grey.
    this is the grey color_grey.PNG On the left is the grey color

    self.first_group = QGroupBox("first", self)
    self.first = QGridLayout()
    self.first_group.setLayout(self.first)
    
    self.layout = MyVBoxLayout()
    self.setLayout(self.layout)
    self.layout.addWidget(self.first_group, 0)
    

    However, when I use QTabWidget to combine two QGroupBox together like below, the background is white. How can I still use the default color from QGroupBox? Why does QTabWidget use different default color, since I created several other Widget, they also use light grey.
    this is the white color_white.PNG On the left is the white color.

    self.all_tabs = QTabWidget()
    
    self.first_group = QGroupBox("first", self)
    self.first = QGridLayout()
    self.first_group.setLayout(self.first)
    
    self.second_group = QGroupBox("second", self)
    self.second = QGridLayout()
    self.second_group.setLayout(self.second)
    
    self._classbox.addTab(self.first_group, "1")
    self._classbox.addTab(self.second_group, "2")
    
    self.layout = MyVBoxLayout()
    self.setLayout(self.layout)
    self.layout.addWidget(self.all_tabs, 0)
    
    R 1 Reply Last reply 11 Aug 2017, 08:15
    0
    • H helloworld12345
      11 Aug 2017, 00:41

      When I use below code, the default background color is light grey.
      this is the grey color_grey.PNG On the left is the grey color

      self.first_group = QGroupBox("first", self)
      self.first = QGridLayout()
      self.first_group.setLayout(self.first)
      
      self.layout = MyVBoxLayout()
      self.setLayout(self.layout)
      self.layout.addWidget(self.first_group, 0)
      

      However, when I use QTabWidget to combine two QGroupBox together like below, the background is white. How can I still use the default color from QGroupBox? Why does QTabWidget use different default color, since I created several other Widget, they also use light grey.
      this is the white color_white.PNG On the left is the white color.

      self.all_tabs = QTabWidget()
      
      self.first_group = QGroupBox("first", self)
      self.first = QGridLayout()
      self.first_group.setLayout(self.first)
      
      self.second_group = QGroupBox("second", self)
      self.second = QGridLayout()
      self.second_group.setLayout(self.second)
      
      self._classbox.addTab(self.first_group, "1")
      self._classbox.addTab(self.second_group, "2")
      
      self.layout = MyVBoxLayout()
      self.setLayout(self.layout)
      self.layout.addWidget(self.all_tabs, 0)
      
      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 11 Aug 2017, 08:15 last edited by raven-worx 8 Nov 2017, 10:00
      #2

      @helloworld12345 said in default background color of QTabWidget and QWidget/QGroupBox:

      Why does QTabWidget use different default color, since I created several other Widget, they also use light grey.

      i guess this comes from the platform style, that tab-widgets (e.g. on MS Windows) have white background. A "normal" QWidget has grey background by default when it's a window, if it's a child i guess it's transparent, unless it is overwritten.

      I can't provide you python code. But you can try to set the palette of the tab-widget and set the QPalette::Window role to transparent.

      Read this for more clarification.

      Or set on the content of the tab-widget setAutoFillBackround( true )

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      H 1 Reply Last reply 11 Aug 2017, 17:31
      0
      • V Offline
        V Offline
        Vinod Kuntoji
        wrote on 11 Aug 2017, 09:07 last edited by
        #3

        @helloworld12345 ,

        By default, tabwdgets have white background. Find the background color of groupbox and set that color to tabwidget.

        C++, Qt, Qt Quick Developer,
        PthinkS, Bangalore

        1 Reply Last reply
        0
        • R raven-worx
          11 Aug 2017, 08:15

          @helloworld12345 said in default background color of QTabWidget and QWidget/QGroupBox:

          Why does QTabWidget use different default color, since I created several other Widget, they also use light grey.

          i guess this comes from the platform style, that tab-widgets (e.g. on MS Windows) have white background. A "normal" QWidget has grey background by default when it's a window, if it's a child i guess it's transparent, unless it is overwritten.

          I can't provide you python code. But you can try to set the palette of the tab-widget and set the QPalette::Window role to transparent.

          Read this for more clarification.

          Or set on the content of the tab-widget setAutoFillBackround( true )

          H Offline
          H Offline
          helloworld12345
          wrote on 11 Aug 2017, 17:31 last edited by
          #4

          @raven-worx

          Great, it works.

          Actually I did try setting QTabWidget setAutoFillBackground(True) previously, but it didn't work.
          Now I tried set VGroupBox setAutoFillBackground(True), then the color changed to light grey which is the exact default color I need.

          Thanks so much, raven-worx.

          1 Reply Last reply
          0

          3/4

          11 Aug 2017, 09:07

          • Login

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