Mermaid - How to set the labels style for flowchart nodes - flowchart

I need to change the style of the flowchart nodes.
I've managed to set the background color and the outline:
style s1 fill:#0000,stroke:#333,stroke-width:2px
However, I do not see how can I control the labels, e.g. set the font color, font family, bold, underline, etc.

In your HTML page, add custom styles that target div.mermaid. For example:
div.mermaid {
font-family: 'trebuchet ms', verdana, arial;
font-size: 30px;
}

Related

How can I set background for a QPushButton's tooltip?

In Qt I set a background image for a QPushButton, then I added a tooltip for this button and the tooltip has the same background image as the button and I couldn't change it with stylesheet, what am I missing?
In my code I have:
button->setStyleSheet("background-image: url(pathToImage);");
button->setToolTip("Click here");
In my style.qss I have:
QToolTip{
background-image: none;
background-color: white;
font-size: 20px;
border: 1px solid black;
}
The font-size and the border works, but the tooltip's background-image is the same as the button's.
I also tried adding another background-image to the tooltip, it didn't worked either.
How can I change the tooltip's background?
You have to specify the QWidget where to apply the property. If you dont do so, it will apply it to all the childrens of the widget.
In your case, to avoid the background image in the tooltip you have to specify that you want to apply that style to a QPushButton widget. The documentation says:
If we want the property to apply only to the QLineEdits that are children (or grandchildren or grand-grandchildren) of a specific dialog, we would rather do this:
myDialog->setStyleSheet("QLineEdit { background-color: yellow }");
In the example you mention, if you want to modify the style of the tooltip and the button, do something like this:
ui->pushButton->setStyleSheet(""
"QPushButton { background-image: url(me.png); }"
"QToolTip { color: #ffffff; background-color: #000000; border: 0px; }");
It will give you something like this
Update:
If you want to apply it to a single object and not the rest of the widgets of the same type, the documentation says:
If we want the property to apply only to one specific QLineEdit, we can give it a name using QObject::setObjectName() and use an ID Selector to refer to it:
myDialog->setStyleSheet("QLineEdit#nameEdit { background-color: yellow }");
So in your case:
ui->pushButton->setObjectName("awesomeButton");
ui->pushButton->setStyleSheet("QPushButton#awesomeButton { background-image: url(me.png); }");
When you set qss with setStyleSheet your stylesheet applies for all children of object. In your case you can avoid this using stylesheet for QPushButton only
button->setStyleSheet("QPushButton {background-image: url(pathToImage);}");

How to use qss to set radio button bold when checked?

I want to let the text of QRadioButton be bold when checked, but normal when not checked by using qss.
I tried this:
.QRadioButton {
font-weight: normal;
background-color: #FFFFFF;
}
.QRadioButton:checked {
font-weight: bold;
background-color: #AA0000;
}
When I checked the radio button, it's background color changed but not the font.
Does anyone know if I am doing it the wrong way?
Setting stylesheet property font to normal and bold should help.
QRadioButton {
font: normal;
background-color: #FFFFFF;
}
QRadioButton:checked {
font: bold;
background-color: #AA0000;
}
The docs do say that font-weight should work, though. You can file a bug for Qt company if that does not work for you. Setting bold and normal via composite font property is also legal and worked for me on many occurrences.

Why does adding stylesheet to QListView change behavior that is not determined by the style sheet itself?

I have a QListView to which I added line separators using the following stylesheet:
listView_->setStyleSheet("QListView::item { border-bottom: 1px solid black; padding: 2px; }");
However something unexpected has happened - on single click on any item in the list, the data vanishes from the display. It comes back on a double click. This is quite weird I think. Why is this happening ?
Here is the QListView
This is what happens as soon as I click on any item:
The data that has just vanished, comes back when I double click (instead of a single click - or selection action)
Why is this happening and how can I avoid it ?
Each item in the view has states, for example a selected state represents an item that is currently selected. Now, if you look at the list without any stylesheet attached, you will notice that selected items have dark blue background and white text. However, when you are assigning this stylesheet
QListView::item { border-bottom: 1px solid black; padding: 2px; }
you are in fact modifiing all states at once, including the selected state, which causes it to have the default white background along with the white text. For example, if you add another property:
QListView::item { border-bottom: 1px solid black; padding: 2px; background:red; }
you will notice, that all items (both selected and not selected ones) will have red background. To fix the issue, you should specify that your stylesheet must be applied only to items that are not selected
QListView::item:!selected{ border-bottom: 1px solid black; padding: 2px; }

How does view's stylesheet interact with model's ::FontRole in Qt model/view environment?

What happens when font family and size supplied by stylesheet of QTreeView differ from the ones returned by the model assigned to it? So far it seems like model's data overrides stylesheet settings. How do I change font of a view with a custom model assigned to it then?
Or to be more precise: if I know I want to style the view with stylesheet - what do I return from model when ::FontRole is requested?
UPD: just in case I am doing something stupid, here is my stylesheet that I assign to qtreeview:
QTreeView::item:selected
{
color: black;
font-family:"Times New Roman", Times, serif;
}
QTreeView::item:has-children
{
font-family: "Comic Sans MS", cursive, sans-serif;
height: 25px;
border-bottom: 1px solid;
border-bottom-color: green ;
border-top: 1px;
}
After some asking around and googling it turned out that styling text in QTreeView should be done on QTreeView instead of QTreeView::item

Difficulty styling a QTreeView with stylesheets

I'm trying to make the parent items in my QTreeView taller, have larger fonts, a custom expanded/collapsed icon in the right and be underlined. Here's my style sheet so far:
QTreeView::item:has-children
{
font: bold 24px;
height: 20px;
border-bottom: 2px groove lightgray;
}
QTreeView::branch:closed:has-children
{
border-bottom: 2px groove lightgray;
image: url(:/images/collapsed.png);
}
QTreeView::branch:open:has-children
{
border-bottom: 2px groove lightgray;
image: url(:/images/expanded.png);
}
Some of the styles are working. The underline on the branch and item only appears when the item has children which is what I wanted. The icon has changed which is also good. However, the "height" and "font" are not being respected and all items have the same height and font. QTreeView::item:has-children seems valid because the border-bottom is respected. If I set "height" for simply "QTreeView::item", all items get that height but "font" still doesn't work. Can anybody help me with the syntax here?
The tree view has the following properties set in designer:
frameShape: NoFrame
frameShadow: Plain
editTriggers: NoEditTriggers
selectionMode: NoSelection
animated: true
headerHidden: true
The rest of the properties are defaults