Results 1 to 2 of 2

Thread: Weird QMenu behavior on Mac

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Weird QMenu behavior on Mac

    Hi!

    When I set palette on QMenu it doesn't seem to be working. The following is the code

    Qt Code:
    1. Selector_Menu::Selector_Menu(QWidget *parent) : QMenu(parent)
    2. {
    3. setMinimumWidth(52);
    4.  
    5. setAutoFillBackground(true);
    6.  
    7. QPalette p = palette();
    8. p.setColor(QPalette::Window, QColor(5, 5, 5));
    9. setPalette(p);
    10. }
    To copy to clipboard, switch view to plain text mode 

    I add actions to this menu from the function where I create this object. Something like this

    Qt Code:
    1. menu = new Selector_Menu(this);
    2. currentAction = menu->addAction("A");
    3. menu->addSeparator();
    4. menu->addAction("B");
    5. menu->addSeparator();
    6. menu->addAction("C");
    To copy to clipboard, switch view to plain text mode 

    Output looks like the Picture1 attached

    When I use stylesheets I get the output which looks like the Picture2 attached

    Qt Code:
    1. RMS_Output_Assignment_Selector_Menu::RMS_Output_Assignment_Selector_Menu(QWidget *parent) : QMenu(parent)
    2. {
    3. setMinimumWidth(52);
    4.  
    5. setAutoFillBackground(true);
    6.  
    7. QString menu_ss = "QMenu { color: white; background-color: black; }" +
    8. QString("QMenu::item:selected { color: grey; background-color: black; }");
    9. setStyleSheet(menu_ss);
    10. }
    To copy to clipboard, switch view to plain text mode 

    Any idea on why is the background not being set properly in the menu. I am using Qt 4.3.1

    Thanks a lot for the help
    Attached Images Attached Images

Similar Threads

  1. Weird behaviour of mouse events and QMenu pop-ups
    By Ishark in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 07:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.