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. Programatically make a tab's text bold
Forum Updated to NodeBB v4.3 + New Features

Programatically make a tab's text bold

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 6 Posters 4.7k Views 2 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.
  • V Vadi2

    I need to specifically choose which tab to make bold, and it can't be just the currently selected - it could be unselected too. Any ideas?

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @Vadi2
    since its random tabs, not sure you can target that with stylesheet.
    I was wondering if text color could work, so instead of Bold, then some color ?
    http://doc.qt.io/qt-5/qtabbar.html#setTabTextColor
    http://doc.qt.io/qt-5/qtabwidget.html#tabBar

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vadi2
      wrote on last edited by
      #5

      A colour is different because the user could have a custom theme that conflicts. I'd really like it bold - like Firefox can and so on.

      1 Reply Last reply
      0
      • aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #6

        can the tabText be HTML? this would allow any kind of formatting, including bold.

        Qt has to stay free or it will die.

        1 Reply Last reply
        1
        • V Offline
          V Offline
          Vadi2
          wrote on last edited by
          #7

          I tried setTabText(i, "<b>testing</b>"); and it did not work.

          1 Reply Last reply
          0
          • V Vadi2

            How can I programatically make a tab's text bold?

            I'm looking to notify the user that they need to look at it.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #8

            @Vadi2
            mmh, haven't tried it, but I think, you can potentially set an Icon, that spans the whole tab width, that would give the illusion a modified Tab-Text ?

            Edit:

            Google search, brought me to this old forum post

            @SGaist and @Goutye
            had the right idea, re-implement paintEvent seems to be agood (the best?) option


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            2
            • A Offline
              A Offline
              Alain38 0
              wrote on last edited by
              #9

              Hi,
              I supposed that you have a QTabWidget and just wants to change the style of one tab button. Have you tried something like:

              myTabWigdet->tabBar()->tabButton(myIndex, 0)->setStyleSheet("MyStyle");
              
              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vadi2
                wrote on last edited by
                #10

                The tab button (X) is not what I'm looking for - I want to grab the tab itself, not the close button within it :(

                D 1 Reply Last reply
                0
                • V Vadi2

                  The tab button (X) is not what I'm looking for - I want to grab the tab itself, not the close button within it :(

                  D Offline
                  D Offline
                  Devopia53
                  wrote on last edited by
                  #11

                  @Vadi2

                  Using re-implemented paintEvent() is too complicated. Rather, i think using something like QProxyStyle would be a better choice.

                  J.HilkJ 1 Reply Last reply
                  1
                  • D Devopia53

                    @Vadi2

                    Using re-implemented paintEvent() is too complicated. Rather, i think using something like QProxyStyle would be a better choice.

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #12

                    @Devopia53 when I read my Interest-Email feed correctly, than the OP has a solution to the problem, with indeed using QProxyStyle. But hasn't updated the topic to solved yet.

                    since when is re-implemented paintEvent() to complicated? Thats about 20 lines of code to get the desired result, in this case at least.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    2
                    • V Offline
                      V Offline
                      Vadi2
                      wrote on last edited by
                      #13

                      Yep, solved with http://lists.qt-project.org/pipermail/interest/2018-April/029734.html. Thanks everyone.

                      1 Reply Last reply
                      4

                      • Login

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