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. Change color text QAction

Change color text QAction

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 8.7k 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.
  • A Offline
    A Offline
    AichaDev
    wrote on last edited by
    #1

    hiii, please i have same QAction in my form and i want to change color text, I have not found how to do it.help Thank you in advance

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      You can use a QWidgetAction like

      QWidgetAction *newAct = new QWidgetAction(this);
      QLabel *label = new QLabel(tr("New"));
      label->setStyleSheet("color: red");
      newAct->setDefaultWidget(label);
      newAct->setShortcuts(QKeySequence::New);
      newAct->setStatusTip(tr("Create a new file"));
      connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
      
      ...
      ...
      menu->addAction(newAct );
      
      1 Reply Last reply
      0
      • A Offline
        A Offline
        AichaDev
        wrote on last edited by
        #3

        I can not apply the style directly on QAction?because I work on an application already prepared and I not master code, voila les images de mon QAction
        http://server.mediazain.com/capture.png

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AichaDev
          wrote on last edited by
          #4

          there to there not a tag as for color in form file ??
          <property name="font">
          <font>
          <bold>true</bold>
          </font>
          </property>

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #5

            QAction does not support styleSheet or Palette as its just a holder class that inherits QObject. Inorder to use stylesheets/color you need to use it a QWidgetAction incase of a QMenu. In the image link where do you use a QAction ?

            check

            1. Customizing QMenu
            2. Customizing QToolButton
            1 Reply Last reply
            0
            • A Offline
              A Offline
              AichaDev
              wrote on last edited by
              #6

              I was able to apply style bold in text QAction in ui file

              <action name="actionBack">
              <property name="icon">
              <iconset resource="../sankore.qrc">
              <normaloff>:/images/toolbar/previousPageOn.png</normaloff>:/images/toolbar/previousPageOn.png</iconset>
              </property>
              <property name="text">
              <string>Précédent</string>
              </property>
              <property name="toolTip">
              <string>Précédent</string>
              </property>
              <property name="shortcut">
              <string>PgUp</string>
              </property>
              <property name="font">
              <font>
              <bold>true</bold>
              </font>
              </property>
              </action>

              there to there not a way to change the color of text? Thank you for your answer.

              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