Hello everyone,
i'm not new to Qt, however i'm very new to applying stylesheets to widgets. That's why i'm posting in this topic. If you feel that i should be posting in the "Programming" section, tell me and i'll delete this post and create it later.
So basically, i have a QTextEdit widget on a dialog, and i'm trying to apply a stylesheet on it. My stylesheet is in a resource file, and contains this:
* {
margin: 0;
padding: 0;
color: Black;
white-space: normal;
font-family: Arial;
font-size: 10px;
font-weight: normal;
}
h1 {
color: Red;
font-size: 11px;
}
h2 {
color: Red;
font-size: 10px;
}
h3 {
color: Red;
font-size: 10px;
}
* {
margin: 0;
padding: 0;
color: Black;
white-space: normal;
font-family: Arial;
font-size: 10px;
font-weight: normal;
}
h1 {
color: Red;
font-size: 11px;
}
h2 {
color: Red;
font-size: 10px;
}
h3 {
color: Red;
font-size: 10px;
}
To copy to clipboard, switch view to plain text mode
Then on my dialog constructor, i do:
// Set up stylesheet on slip summary widget.
QFile fStyle
(":/Resources/Stylesheets/SlipSummary.css");
fStyle.
open (QIODevice::ReadOnly|QIODevice
::Text);
_ui.txtSlipSummary->setStyleSheet(fStyle.readAll());
fStyle.close();
// Set up stylesheet on slip summary widget.
QFile fStyle(":/Resources/Stylesheets/SlipSummary.css");
fStyle.open (QIODevice::ReadOnly|QIODevice::Text);
_ui.txtSlipSummary->setStyleSheet(fStyle.readAll());
fStyle.close();
To copy to clipboard, switch view to plain text mode
My main problem is that no titles are being shown in red. If i put the "color: red" on the first "*" selector, everything turns red, but no luck with the individual selectors... What can be the problem?
Related to styling widgets, i have a question. Lets say a QTextEdit base contents is set to:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta name="qrichtext" content="1" />
</head>
<body>
<h1>Test</h1>
<h2>Foo</h2>
<p>Bar</p>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta name="qrichtext" content="1" />
</head>
<body>
<h1>Test</h1>
<h2>Foo</h2>
<p>Bar</p>
</body>
</html>
To copy to clipboard, switch view to plain text mode
Then would it be possible to set a stylesheet which would be in a QRC file like this within the <head /> tag:
<LINK href=":/Resources/CSS/Main.css" rel="stylesheet" type="text/css">
<LINK href=":/Resources/CSS/Main.css" rel="stylesheet" type="text/css">
To copy to clipboard, switch view to plain text mode
Thanks a lot for your help,
Pierre.
Bookmarks