Results 1 to 7 of 7

Thread: background color of menu bar

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default background color of menu bar

    Hi,
    How can I set the background color of menu bar as black in a QMainWindow.

  2. #2
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: background color of menu bar

    try same code as main window.
    change m_pMenu with your menu variable.
    Qt Code:
    1. QPalette palette;
    2. palette.setColor(m_pMenu->backgroundRole(), Qt::black);
    3. m_pMenu->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to rajesh for this useful post:

    ntp (23rd October 2007), sabeesh (25th July 2007)

  4. #3
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: background color of menu bar

    Hi,
    Thankyou, it is working

    Sabeesh

  5. #4
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: background color of menu bar

    Hi,
    One small problem found. When I use the above command, then I can change the background colour of menu bar. But the problem is that, when I add a Table Widet, then its Scrollbar color and Column and Row heading color also change. I need to change only the menubar color of Main Window. How can I do this.

    Sabeesh

  6. #5
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: background color of menu bar

    can you post your code here? how you changing the color of menu?

  7. #6
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: background color of menu bar

    Hi,
    This is the code,

    QPalette palette;
    palette.setColor(menubar->backgroundRole(), Qt::black);
    palette.setColor(menubar->foregroundRole(), Qt::white);
    menubar->setPalette(palette);

    Sabeesh

  8. #7
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: background color of menu bar

    Hi,
    I have a Table View in my form. I had add some rows into that Table Widget. I need to hide the row heading of that Table Widget. How can i do that. Please help me.

    Sabeesh

Similar Threads

  1. Docked Widget Menu
    By Chuk in forum Qt Programming
    Replies: 6
    Last Post: 3rd July 2013, 14:12
  2. Menu bar background color focus
    By user_mail07 in forum Qt Tools
    Replies: 0
    Last Post: 18th May 2007, 01:25
  3. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 11:47
  4. Background image on popup menu item
    By MarkoSan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th June 2006, 05:55
  5. Replies: 1
    Last Post: 5th April 2006, 16:44

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.