Customize QScrollBar intersection using stylesheet Qt - c++

I’ve already customize my horizontal and vertical scrollbars using a stylesheet no problem.
But there still an annoying tiny area which remains blank :
The intersection of an horizontal and vertical bar. A small rectangle.
How could I change its color ? (Using stylesheets )
Thank you !
Qt 4.7.1 on Mac OSX Snow Leopard
Ps: Even on the Qt stylesheet example it’s still white.

I realise this is an old question, but I found a better solution.
QAbstractScrollArea::corner {
background: somecolor;
}
Or, to hide it, use:
background: transparent;

By default, the scroll area corner will be painted with the Window palette. Unfortunately, you cannot change the Window palette using only stylesheets. However, what you can do is create a dummy widget and set it to be displayed in the corner area with QAbstractScrollArea::setCornerWidget(QWidget *widget), and then use the stylesheet to change the color of that widget.

Related

svg icons appears pixelated on high DPI

Some of my SVG icons don't scale properly on scaling a monitor (Win10) or use a highDPI monitor (Win10, Linux, Mac). This applies to icons assigned to a QAction and displayed by QMenu entries or QToolButtons, and icons assigned to QDockWidgets, as shown in the upper part of the attached screenshot.
The icons in the lower part are painted in the derived paintEvent(..) and render perfectly.
Using the option QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); The system seams to use some scaling heuristic on a pixmap so the icon becomes somehow edgy:
Is there any way to make qt redraw the icon on the SVG base without the need to derive all icon-showing classes?
Sincerely
JJ
I had this issue with SVG icons too. Turns out for me it was caused by an aspect ratio difference between the SVG file and what I tried to render it as. I tried to render as a square but my SVG file was not square. Setting square dimensions in the SVG file fixed it.

Set background color for QTabBar beyond tabs?

Simple as the question title, I have a QTabWidget and I wanted to set the background color for the QTabBar area, and this is how I do it:
ViewTabs->tabBar()->setStyleSheet("background-color: rgb(85,85,85)");
I expected this to set the back ground for the whole bar, but instead it sets the background on tabs only as in the attached picture.
How do I make the background color take effect even beyond the tabs? I'm using QT 5.7 with C++.
You can try to change the background color manually in the UI interface by clicking on "palette" in the proprieties.
It's easier to handle colors this way.

Splitter in Qt5 is invisible

I have been creating a small frame window with a splitter object, using the Qt Designer. What is strange though is, that the splitter is working, so when I move the mouse where it should be, the cursor switches it's shape and I can drag the splitter, but the splitter bar itself is invisible.
Is this a bug from Qt5? I'm using Qt 5.2.1 OpenSource with MingW on Windows 7.
(source: picr.de)
Update
I created now a bugreport for this issue
I have also invisible splitter (Using Qt 5.3).
But I am using some complex style sheet which colors it in a way I need and it is visible that way:
QSplitter::handle {
background-color: #333;
}
Please check the docs how to apply style sheet.

Adding/resizing a background image to centralWidget in Qt

I'm new to Qt. I searched for my question on multiple sites, but I couldn't find an answer. How can I add an image to centralWidget?
I tried:
MainWindow w;
w.centralWidget()->setStyleSheet("image: url(image)");
it worked fine but the image isn't stretched for the entire window/widget. How can I resize the image through setStyleSheet?
I want to display an image in the background and not the gray color, when the application opens. I tried changing the color. That worked, but it doesn't look good with buttons and labels.
If you want it to stretch for the entire widget use background-image, but I'm guessing what you probably want is an image that expands in one direction, either vertically or horizontally, in that case use background-position to fix it to one of the borders of your widget:
image: url(:/path/to/image);
background-position: bottom left;

QWidget background color does not fully cover the QWidget

Using Qt Creator, I have set a QWidget's background property to black. However, some parts of the QWidget, more specifically, between QFrames/QGroupBoxes are still in its system's default color.
Now, I thought that the QFrames and QGroupBoxes need to have its background property set to black too, but it did not work. I have also tried setting the border-color to black, but it does not work, since by default borders, margins are set to 0.
QWidget { background: black; }
Any advice on this issue?
EDIT
The QWidgets are placed in QMdiArea. However, if I make it a QWindow, it works. However, I want the QWidgets to be in the QMdiArea. Also, if I just show the QWidgets as it is, the spaces that I have mentioned above are transparent.
It sounds like you have some widgets within another widget, and are setting the contained widgets to be black, but then the space between them is not black. If that is the case, it is likely because you have a layout in the containing widget, which allocates space between each contained widget. The empty space between widgets will be drawn with the containing widget's background color.
Found out the solution. It seems that you need to set the background color at the QMdiSubWindow, not at QWidget. Don't know why, but it seems logical.