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 add a stylesheet to a QAction item from a QMenu?
QtWS25 Last Chance

How to add a stylesheet to a QAction item from a QMenu?

Scheduled Pinned Locked Moved Unsolved General and Desktop
stylesheetaction
3 Posts 2 Posters 4.5k 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.
  • T Offline
    T Offline
    TiagoAM
    wrote on 18 Feb 2016, 17:22 last edited by
    #1

    I'm trying to create a stylesheet to a QAction inside a QMenu item, and I've tried a lot, but can't to work.
    I want to change the QAction text property, for the QMenu it worked alright.
    This is how I did with the menu ```
    QMenu#qmSelf {
    qproperty-title:"MAIN MENU";
    }

    This how I tried with the action
    

    QAction#qaUSER{
    qproperty-text:"USER";
    }

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 18 Feb 2016, 18:16 last edited by
      #2

      Hi, welcome to devnet.

      Stylesheets only apply to widgets. QAction is not a widget. You could probably hack it with QActionWidget and for example a label, but that's gonna be tricky.

      It's a very unusual thing to set text via stylesheets. They are really meant to define the looks, not the content. You're missing out on many text related features this way, like localization. Are you sure it's a good idea?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TiagoAM
        wrote on 18 Feb 2016, 18:31 last edited by
        #3

        Hi, well the case is that I was trying to build mumble with QtCreator and I couldn't get it to build the application, I thought why not set it using stylesheet. I'll have to fight with Qt again, thanks for your reply.

        1 Reply Last reply
        0

        2/3

        18 Feb 2016, 18:16

        • Login

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