In Qt (for a Maya plugin), I have a QSplitter containing 2 QGraphicsViews.
One of these QGraphicsViews contains some QLineEdits.Whenever I click on one of these QLineEdits, it gets a blue border (focus), but the QGraphicsView gets a blue border too. How to avoid the QGraphicsView to get a blue border ?
You can try setting style sheet eg:
QGraphicsView:focus {
border: none;
outline: none;
}
Related
I have been trying to set the background color of a QTabWidget to black (or any other color for), but have been unsuccessful in doing so.
It seems that you need the option autoFillBackground set and then also set "background-color: black;" in the stylesheet. This then displays it properly in the Designer, but fails in the application.
This answer suggests to enclose it in another QWidget and then use the transparency, but that is a hack around the issue.
How do I set the background color of a QTabWidget via stylesheets?
EDIT
Setting QTabBar { background-color: black; } results in the following image.
As an alternative to QTreeWidget, use QTabBar + QStackedWidget and the following stylesheet
QTabBar { background-color: black; }
or use
Qt: Styling QTabWidget
I have a Qt application that, among many other widget types, uses a QTabWidget. I'm having difficulty styling the background color for this object.
I've tried some of the following lines, which I found from other forum posts, in my stylesheet with no effect on the program
QTabWidget { background-color: black; }
QTabWidget::pane { background-color: black; }
QTabWidget#tabWidget { background-color: black; }
QTabWidget#tabWidget::pane { background-color: black; }
If I use QWidget { background-color: black; }, then yes my color is properly changed, but then all of the other widgets in my program are changed as well... so this isn't what I'm looking for...
I've also tried it in code with ui->tabWidget->setStyleSheet("background-color: black"); But this too is undesirable because it changes the background color of all of its children widgets.
Does anyone have any other ideas on how to style a QTabWidgets contents background area?
About a year late but I recently ran into the same problem and got it working.
First of all QTabWidget has a child QWidget for every tab you make. That is the area that you put your other widgets into, and that is what you want to set the background color of.
Set the style-sheet by doing this.
1)Determine the name of your tab widgets from the design object window top right, they should match the currentTabName that you set when creating your tab.
2)Realize this is a QWidget not a QTabWidget this is why QTabWidget { background-color: black; } does not work.
3)Realize that by specifying the object in the style-sheet with the '#' the child object will not inherit the style-sheet.
For me I specified my style-sheet as such, repeating for each tab object name that I had:
#objectName {background-color: rgb(240,240,240);}
This provided me with the exact behavior I needed. In my case I wanted to get the natural gray background onto my Tab pages but not override the child components on the tab pages.
I hope this helps someone in the future...
I want to make QWebView widget have borders in my layout and UI when running, similar to QTableView. Now it looks borderless and hidden.
Is it even possible?
It's not possible to set border to QWebView. Instead you can place your QWebView inside another QWidget and set it's border. See example below (QtDesigner):
Widgets hierarchy:
Look inside QtDesigner:
StyleSheet for QFrame:
QFrame
{
border: 1px solid black;
background: white;
}
I want the QtextEdit in my app to be green so I set the stylesheet to
background-color: rgb(109, 255, 99);
However this also change the background color of the scrollbars and even when I click mouse right button in the textedit the menu that is shown is also green and that is not what I expected.
I'm using Qt Designer to design gui and then I used the uic to generate c++ file.
in the c++ file it looks like this:
textEdit->setAutoFillBackground(false);
textEdit->setStyleSheet(QString::fromUtf8("background-color: rgb(109, 255, 99);"));
textEdit->setReadOnly(true);
Anybody know how to set the background color only for the area where text would be?
Thanks
All child objects of your text edit inherit the stylesheet, so all children (e.g. context menus) will have a green background.
You should select your QTextEdit only in your stylesheet, i.e.
textEdit->setStyleSheet("QTextEdit { background-color: rgb(109, 255, 99) }");
Note that you can set the stylesheet at application level, too, so that all QTextEdit's in your app will have your specified background:
qApp->setStyleSheet("QTextEdit { background-color: rgb(109, 255, 99) }");
In my app, i have a section that is top widget, the color of the top widget is gray, and i've been put severl widget on top widget, like QComboBox, QLineEdit and 2 QButton, but i have a problem when i right click on QLineEdit as you seen in below picture, the color of default context of window is gray, or when i open the QComboBox the color of background is gray. I'll set the background color of two these widget to white but doesn't work. So, how can i fix this?
Sample for better understand:
http://0000.4.img98.net/out.php/i52512_problem.png
Please help me
The style sheet propagates to all the child widgets, so you have to limit their range by using the right selectors. Since the context menu is a child of the QLineEdit it is also affected.
// What you have probably done:
myLineEdit->setStyleSheet("background-color: gray");
// What you should have done:
myLineEdit->setStyleSheet("QLineEdit { background-color: gray }");
// What you should do if there might be child widgets of the same type
// but for which you don't want the style to apply:
myLineEdit->setObjectName("myLineEdit");
myLineEdit->setStyleSheet("QLineEdit#myLineEdit { background-color: gray }");
See "The Style Sheet Syntax - Selector Types" for details.