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's tab text alignment not working

QTabwidget's tab text alignment not working

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 2.9k 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
    saber
    wrote on last edited by saber
    #1

    i am trying to show the opened tab text in left .i wrote that in stylesheet.but it is not working.

    i am trying to show the opened tab text in left .i wrote that in stylesheet.but it is not working.

    here is the stylesheet i used.

    QTabWidget QTabBar{
    background-color: #373738;
    height: 30px;
    }
    
    QTabWidget QTabBar::tab{
    text-align: left;
    background-color: #136ba2;
    border-style: 1px rgb(67, 67, 67);
    height: 30px;
    width: 130px;
    color: #136ba2;
    padding: 0px 5px 0px 5px;
    }
    
    QTabWidget QTabBar::tab:selected{
    background-color: #5A5B5C;
    font-weight: bold;
    color: #ffffff;
    }
    QTabWidget QTabBar::tab:!selected{
    background-color:#353536;
    color:  #B4B4B4;
    }
    QTabWidget QTabBar::tab:hover{
    background-color:  #5A5B5C;
    color:  #ffffff;
    }
    

    0_1518599311018_vd.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, you can't do that like that. You can maybe play with the left property but be aware that you are doing something that your users might not like. Many people will be surprised seeing their tab text moving around just because they selected a tab.

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saber
        wrote on last edited by
        #3

        here is the solution from stackoverflow.
        thanks.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          haris123
          wrote on last edited by
          #4

          @saber said in QTabwidget's tab text alignment not working:

          text-align: left;

          One workaround I found is add some extra space at the end of the title;

          QString tabTitle = "Page 1                          ";
          
          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