How to change the theme color with SwiftUI? - swiftui

I need to change the title of all the navigationlinks to a different color other than blue, like a custom green. Don't know where to begin.
Example

Use accent color like the following
NavigationView {
// content here
}.accentColor(Color.green)

Related

adding colour in a django models.TextField

I have a model in django:
introduction = models.TextField(null=False, blank=False)
When writing in the text field I want the colour of the middle section to be different from the rest. Any ideas how I do this how to set colours in the textfield?
I'm not sure I get what you mean by 'middle section', but regardless, this would have to be done in client-side since what you want is to manipulate something like the color of a certain TextField. You could do it by using the CSS color properties or even Javascript.
give your textfield an identifier in your html code ,
like, id="tf"
then css will be
#tf{
color : #aaaaaa;
}
write your color code in place of #aaaaaa.

QGraphicsOpacityEffect on QTextField on Windows 7 -- strange behavior

I am attempting to add a fade-in/fade-out effect to a widget (that contains other widgets, including buttons and text fields).
The problem is that while buttons fade perfectly, text fields do not - instead of changing opacity of the text field, only the opacity of its border changes.If the text has been selected before changing opacity, after the opacity is reduced, the selection looks strange.
What can be the cause of this problem and how to make the fade effect on all widgets, not only push buttons?
The problem can be easily reproduced, if you place a QTextField on form, and add the following code to button handlers:
void MainWindow::on_pushButton_3_clicked()
{
QGraphicsOpacityEffect * effect = new QGraphicsOpacityEffect(ui->plainTextEdit);
effect->setOpacity(0.1);
ui->plainTextEdit->setGraphicsEffect(effect);
}
After this code is run, you will see something like this:
Image1
void MainWindow::on_pushButton_4_clicked()
{
QGraphicsOpacityEffect * effect = new QGraphicsOpacityEffect(ui->plainTextEdit);
effect->setOpacity(1.0);
ui->plainTextEdit->setGraphicsEffect(effect);
}
The text field looks like this, after this method is executed:
Image2
Thanks.

Change highlight color in QWebView

I want to change to color in which text is highlighted when the findText() method is used. This color has nothing to do with user selected text. I have tried CSS as well as setting a QPalette. All occurences are always highlighted in yellow.
I've been searching for this as well, and it seems like it's hardcoded deep inside WebKit:
Color RenderTheme::platformInactiveTextSearchHighlightColor() const
{
return Color(255, 255, 0); // Yellow.
}
I really have the same problem. But the good news: Setting the style sheet helps at least to change the fg/bk color.
m_browser->setStyleSheet("QWebView {
selection-background-color: blue; selection-color: white; }");
But this is not the whole truth because it only changes the fg/bk color of the currently found text. No idea how to change the fg/bk color of all occurences.
Axel

QToolButton and color

I'm trying to make a simple design to select a color and I'm using a QToolButton to open a QColorDialog.
My problem is that I would like the QToolButton to be of the selected color but I've only suceeded to set the background color, which is not what I want.
Here is a picture:
My code:
QColor color = QColorDialog::getColor(m_couleur);
if (color.isValid()) m_couleur=color;
m_labelCouleur->setPalette(QPalette(m_couleur));
m_labelCouleur->setAutoFillBackground(true);
m_buttonCouleur->setPalette(QPalette(m_couleur));
m_buttonCouleur->setAutoFillBackground(true);
Basically I would like the QToolButton to look something like this:
edit: Can anyone explain to me why the website won't let me add "Hi everybody" at the beginning?
QColor color = QColorDialog::getColor(m_couleur);
QPixmap px(20, 20);
px.fill(color);
m_buttonCouleur->setIcon(px);
No CSS involved in this case is (for me ofcourse) big pro
Use the setStylesheet function in order to change the background color of your button
m_buttonCouleur->setStyleSheet(QString("QToolButton{ background: %1; }").arg(m_couleur.name()));
I've done exactly that by using a QPushButton and setting its style sheet to the result from the color picker. I guess a tool button should probably be the same.
button->setStyleSheet(QString("background-color: %1; "
"border: 1px; "
"border-color: black; "
"border-style: outset;").arg(color.name()));

QTableView with an editor for all fields

I am trying to modify the QTableView to always show all editors. I am ok with the workaround to call openPersistentEditor() on all cells.
However I'd like the content of the cells to not be selected and no text cursor for empty fields.
This is what I get:
And this is what I'd like to have:
I tried using clearSelection() and clearFocus() but that does not do the trick. If I click on each cell I get the desired result and I could do the same thing programmatically, but I'd to know if there's a more direct way.
I had this exact same issue. I ended up just adjusting the selection color and selection background color on the QLineEdits. You can do it on all QLineEdits or just on a custom QLineEdit by giving each editor an object name and referencing that in the stylesheet.
/* applies to all QLineEdits in the application */
QLineEdit {
selection-background-color: white;
selection-color: black
}
/* applies to all QLineEdits with the object name "custom" in the application */
QLineEdit#custom {
selection-background-color: white;
selection-color: black
}