Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Stylesheets: How to apply style to menus? How to remove blue tinge around QTextEdit?

I am trying to make the menubar a gradient black colour and that works fine, except for the menu headings.

Here's the stylesheet i'm using:

 QString styleSheet = "QMenuBar{background: qlineargradient(x1:0,x2:0,y1:0,y2:1,stop:0 #cccccc, stop:0.4 gray)} QStatusBar{background: qlineargradient(x1:0,x2:0,y1:0,y2:1,stop:0 #cccccc, stop:0.4 gray);color:white;} ";

this->setStyleSheet(styleSheet);
  1. How do I apply the style to the meny headings too?
  2. There is a blue tinge all around the QTextEdit which I can't get rid of. Is there a way to set it to black?

Thanks :)

stylesheet not applied to menu items

like image 340
W.K.S Avatar asked Jan 02 '12 21:01

W.K.S


People also ask

How do you change a styleSheet in Qt?

You can right-click on any widget in Designer and select Change styleSheet... to set the style sheet. In Qt 4.2 and later, Qt Designer also includes a style sheet syntax highlighter and validator.

Does Qt Designer use CSS?

Qt allows you to decorate your Graphical User Interfaces (GUIs) using a style sheet language called Qt Style Sheets, which is very similar to Cascading Style Sheets (CSS) used by web designers to decorate their websites.

How do I add menu bar to QT?

In most main window style applications you would use the menuBar() function provided in QMainWindow, adding QMenus to the menu bar and adding QActions to the pop-up menus. Example (from the Menus example): fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(newAct);


2 Answers

I believe that the following website is a good resource for answering your question about the QT menubar issue you are having:

http://www.trinitydesktop.org/docs/qt4/stylesheet-examples.html#customizing-qmenubar

It gives a few code samples which should fully explain what you need to know. As for the blue tinge, I do not have a good idea on how to fix it - I haven't really seen that happen.

Best of luck.

like image 172
nmagerko Avatar answered Sep 17 '22 06:09

nmagerko


This solved the problem for me:

QMenuBar::item {
    background-color: transparent;
}
like image 25
jminardi Avatar answered Sep 19 '22 06:09

jminardi