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 change QTabBar close button size
Forum Updated to NodeBB v4.3 + New Features

How to change QTabBar close button size

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.1k 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.
  • M Offline
    M Offline
    M_Shao
    wrote on last edited by
    #1

    I saw the post from 2013, but now at 2021, I hope there is a better solution.
    https://forum.qt.io/topic/36002/changing-qtabbar-close-button

    I'm trying change the size of QTabBar close button. The setClosable() make this button appears, but it looks like a 16x16 png icon so even I set the styleSheet to the new width and height doesn't work. Then I change the icon to my own svg icon, it's still not working. Is it correct that width and height setting from stylesheet for this close button just doesn't work? Is there any way to change the size of this close button without subclassing and writing close related functions? I wish there are methods from QTabBar to customize the close button.

    Any help/info would be appreaciated.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Did you already checked QTabWidget::iconSize ?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      ytexasY 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Did you already checked QTabWidget::iconSize ?

        ytexasY Offline
        ytexasY Offline
        ytexas
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        Tried QTabWidget::setIconSize and QTabBar::setIconSize , close icon size won't change.


        Also I tried set a qss:

        QTabBar {
        icon-size: 8px;
        }
        
        QTabBar {
        icon-size: 8px 8px;
        }
        

        Still cannot change icons size;


        doc reference:
        https://doc.qt.io/qt-6/stylesheet-reference.html
        https://doc.qt.io/qt-5/qtabbar.html#iconSize-prop

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Langton_
          wrote on last edited by
          #4

          using margin moves and resizes the button for some reason:

          QTabBar::close-button{
          image: url(:/icons/images/black_cross.png);
          margin-right: 7px;
          margin-top: 7px;
          }

          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