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. Changing stylesheet or tooltip in one go
Forum Updated to NodeBB v4.3 + New Features

Changing stylesheet or tooltip in one go

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.0k 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.
  • mit_cruzeM Offline
    mit_cruzeM Offline
    mit_cruze
    wrote on last edited by A Former User
    #1

    I have made one large project using Qt designer which has .ui, .cpp, .h files.
    Now I want to add colors and tool-tip to pushbuttons of all .ui files in one go or some easy way, because it WOULD BE VERY DIFFICULT TO GO THROUGH ALL .ui files and change color of each pushbuttons.
    Is there anyway I can do this?
    If you are not sure you can share your ideas.
    Please.

    raven-worxR 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      stylesheets are cascading. Do not assign to each button.!
      so if you assign stylesheet to mainwindow, then
      all buttons owned by mainwindow or children with buttons would all be affected.
      If you have parentless dialog, its not affected. ( as not a child)
      But you can set same stylesheet on such windows.

      Regarding tooltip. how would that be possible, you would need a list that says
      thisbutton, that text
      so how can a program know what text to use ?

      1 Reply Last reply
      2
      • mit_cruzeM mit_cruze

        I have made one large project using Qt designer which has .ui, .cpp, .h files.
        Now I want to add colors and tool-tip to pushbuttons of all .ui files in one go or some easy way, because it WOULD BE VERY DIFFICULT TO GO THROUGH ALL .ui files and change color of each pushbuttons.
        Is there anyway I can do this?
        If you are not sure you can share your ideas.
        Please.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @mit_cruze

        QPushButton {
            color: red;
            background: white;
           border: 1px solid grey;
        
            qproperty-toolTip: "Same ToolTip for all buttons";
        }
        
        /* define special buttons by setting the object-name */
        QPushButton#SpecialButton {
            qproperty-toolTip: "Special ToolTip";
        }
        

        if you set the stylesheet on the QApplication instance, all windows (even parentless ones) will receive it.

        But note that you wont be able to translate the tooltip text, when it's set via stylesheet.

        --- 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

        1 Reply Last reply
        3
        • mit_cruzeM Offline
          mit_cruzeM Offline
          mit_cruze
          wrote on last edited by
          #4

          thanks @mrjj @raven-worx

          mrjjM 1 Reply Last reply
          1
          • mit_cruzeM mit_cruze

            thanks @mrjj @raven-worx

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

            @mit_cruze
            let us know
            if you find a good way of setting different
            tooltips on all the buttons. :)

            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