Set background color for QTabBar beyond tabs? - c++

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.

Related

Qt widget blurred semitransparent background on Linux

Working with widgets, c++ and Linux
need something kind of:
this
but no borders and custom title.
Search for a few days, but nothing.
For now, there is a widget with setWindowFlags(Qt::FramelessWindowHint); and a peace of qss for semitransparent background. How can I blur it? Is is possible at all?
I do not think this can be done with Qt. Blurring can be done using https://doc.qt.io/qt-5/qgraphicsblureffect.html but it is only limited to the widgets painted by Qt. Which the underlying background is not, even if you manage to make your widgets transparent or semitransparent. Painting the background is always the business of the operating system (or window manager) and not the business of your application Qt.
You can certainly try to do some extreme hacking like grabbing the active screen before your window is displayed (see How to capture the current screen image using Qt?) then getting certain rectangle content of the image, which corresponds to the background of your window, then paint it blurred to the background of your application and then update it everytime you move or resize your window... But anyway, even if you manage this, this background will be static and not dynamic.
I recommend that you abandon the idea of blurry background and leave this function to the window manager and the operating system.

How to add a myOwn-background image to QPlainTextEdit?

For example, if you create a simple plaintextedit, the background is just white. How do I change white background with my own image?
In design edit, you can set the styleSheet in properties of QWidget. In c++ code you can set the background using QSS, for example, setting
‍‍‍‍background-image: URL("path/image.png");:
myWidget->setStyleSheet("background-image: URL('path/image.png')");

Specific QPushButton style

How can I customize the look of a QPushButton or QToolButton to look something like elementaryos's webpage "buttons"?
All I really want is the characteristic image position and the text on it's side, maybe if i'm lucky i can also get a border like that, but i don't really need the little description below the title :)
Can i do it only with StyleSheets, or do i have to subclass QPushButton/QAbstractButton/Something like that? I already searched everywhere but didn't found that level of customization without things like painting something in a fixed place, which is exactly what i don't want.
EDIT:
I really would like a solution that would get me a customizable button, not a fixed image one, something in the tracks of
MainWindowButton(QString(title), /*opt*/QString(description), QImage(icon));
There are a number of approaches that may work.
You might first consider trying to compose a solution with a normal QPushButton with a QVBoxLayout on it. You could add three QLabels; one for the title text, one for the caption text and one for the image. Some CSS could probably be used to render the background image of the button for up and down and more CSS to style the text in the two labels and position the image on the third but you would then find that the labels don't shift down when the button is clicked.
I think the best solution involves direct painting. You could do this by sub classing a QWidget and overriding the paintEvent(). Render everything for the up state and shift everything over and down a bit for the down state.
You could achieve this without sub classing by rendering the up and down states to a QImage and styling a QPushbutton with them using CSS.
There are a number of combinations of these approaches too.
You can set the background as white with the icon in the right corner with some creative use of the border-image stylesheet property where the bottom border is as tall as the icon and the top, left and right borders are 0 pixels wide. You'll need to make a custom image that basically looks like the icon with a couple pixels width on the left and top that are white
http://doc.qt.digia.com/qq/qq20-qss.html#theboxmodel
The text you may have to do overriding paintEvent.

Customize QScrollBar intersection using stylesheet Qt

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.

Changing TabControl tab title text background color c++

I am using Visual Studio 2005, C++, and I have a tabcontrol with a couple tabs. I have changed the color of each tab to have a back color of Transparent, to match the color of the rest of the program (Control grey), however the color behind the text for the title of the tab is white. Is there any way to change this?
A tab control draws itself according to the currently selected windows theme. Which ignores a custom color. This isn't something you ought to change, you typically want to honor the user's attempt to style the windows according to her selected preference.
If you really do want to override it then you can use custom drawing, the TCS_OWNERDRAWFIXED style flag and the WM_DRAWITEM message. Beware that drawing with a transparent color isn't going to work.