Skip to content
  • 0 Votes
    5 Posts
    531 Views
    B

    @mrjj
    I have the following stylesheet applied to a containing widget

    QMenu, QMenu QPushButton { background-color: #303030; color: white }

    When I remove the QMenu selector, the white line disappears (hence it starts looking like this)
    10a42cae-0e1b-4d97-88b6-eacbaec7e038-image.png

    I cannot say whether the white line really disappears or it just blends with the white color of the menu item.

    After applying the same style with a QMenu::item selector, I get the following:
    5ffa874d-36f1-4742-a31a-078469ec6e2f-image.png
    The ordinary menu items are colored, but those created by my class are not. It appears as if the ::menuItem selector does not work on them.

    I also tried setting the following style rule on the container returned by the createWidget function

    container->setStyleSheet(".MenuItem {background-color: #303030; color: white; }");

    and it oddly makes the custom menu items get shifted to the left and the hover effects on them do not seem to work any longer. Applying padding/margin does not fix it:

    4132b0aa-b742-4af9-aa91-eeeb961b6aab-image.png

  • 0 Votes
    2 Posts
    2k Views
    SGaistS

    Hi and welcome to devnet,

    What about painting a partially transparent rectangle over the part of the text that should be highlighted ? You could draw the text first and then the rectangle over.

    Hope it helps