How to set tab background color - c++

I am trying to set the colour of all the white space in a tab that I have using QSS.
In the image you see what it currently looks like.
This next image is what happens if I use
"background-color:black;"
You can see that it HAS made the background black, but I want to fill in the surrounding white area too.
Anyone know how this is done?
I have my items collected together in various QHBoxLayout

Related

How do I change the text color of the inline breakpoint settings?

I use a dark theme, and I have my code "peek" background set to a dark color as well.
In VS2017, instead of the older dialog window you'd get when modifying a breakpoint, you get the settings inline instead, similar to how the "peek" bits look.
However, I can't find a way to change the text color of this area, so now I am trying to squint at dark grey text on a dark purple background. It seems as though the "peek" background color is shared with the breakpoint settings.
Is it possible to change this color?
Here's an image to show you what I mean:

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.

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;

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.

Qt: background for QtAbstractItemView (QTableView) while editing an entry

I have the following question.
My QTableView has background color set to black and color (of contents) to white. So, white text appears on a black background - everything seems to be correct. However, when editing (typing in editing mode) content color is changed to black and it becomes completely invisible due to black background, but editing works fine. After confirming - color reverts back to white. How to set color of currently-being-edited text to white (preferably via stylesheets) or stop such change in this case?
You have to use the :edit-focus and/or :focus states in your stylesheet.
QTableView:edit-focus {
// style here
}
For a list of all available states have a look here
Setting palette worked finally.
QPalette palette;
palette.setColor(QPalette::Text, Qt::white);
qApp->setPalette(palette);