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. Qmenu popup button style problem

Qmenu popup button style problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 950 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.
  • D Offline
    D Offline
    dkmiraidk
    wrote on last edited by
    #1

    I'm trying to style the button in the popup of a QMenu, but can't get to style it.

    I'm programming in VS2015, and have tried menu different thing but can't get it to work.

    The code I have tried in VS is:

    QMenu *ObjectsMenu = new QMenu();
    QPushButton *Button = new QPushButton();
    ObjectsMenu->setStyleSheet("QMenu::item:hover { background-image:url(F:/Izanagi Games/TWE/UI/TextBox_NotSelected.png);} QMenu::QPushButton {background-color: rgb(255,0,0);}");
    Button->setMenu(ObjectsMenu);
    ObjectsAction = new QAction("Test menu", this);
    ObjectsMenu->addAction(ObjectsAction);
    ObjectsButton = new QToolButton();
    ObjectsButton->setMenu(ObjectsMenu);
    ObjectsButton->setPopupMode(QToolButton::InstantPopup);
    ObjectsButton->setIcon(QIcon("F:/Izanagi Games/TWE/UI/ObjectBut_NotSelected.png"));
    ui.toolBar->addWidget(ObjectsButton);
    

    But i can't figure out hoe to style the actual button style, so does anyone know how to style the button (and i know the button is a QPushButton)?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @dkmiraidk
      QMenu::QPushButton {background-color: rgb(255,0,0);}");

      The stylesheet expects a sub-control rather than a control if you use ::
      At the most you can try:
      QMenu#pushButton { ... } //pushButton = objectname of QPushButton

      Or since you already have a separate QPushButton object you can directly apply stylesheet to it ?

      157

      1 Reply Last reply
      2

      • Login

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