<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Larry<div><br></div><div>Problem solved by specifying the styleSheet. Thank you very much for your help and your detailed explanations!</div><div><br></div><div>Regards,</div><div>Josua</div><div><br><br><div><hr id="stopSpelling">Date: Thu, 13 Jun 2013 10:58:44 -0600<br>Subject: Re: [Qgis-developer] Font size problem<br>From: larrys@dakotacarto.com<br>To: josh-talk@hotmail.com<br>CC: qgis-developer@lists.osgeo.org<br><br><div dir="ltr">Hi Josua,<br><div><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">On Thu, Jun 13, 2013 at 7:15 AM, Josua S <span dir="ltr"><<a href="mailto:josh-talk@hotmail.com" target="_blank">josh-talk@hotmail.com</a>></span> wrote:<br>
<blockquote class="ecxgmail_quote" style="border-left:1px solid rgb(204,204,204);padding-left:1ex;">Hello<br>
<br>
I am working on a QGIS Python plugin and I have a problem concerning font sizes. With QDialogs I have no problem to set the font sizes. But as soon as I work with a QDockWidget and add it to QGIS every font size settings are ignored. Qt Creator shows the correct font sizes but QGIS seems to overwrite these settings. Does this behaviour have a reason and is there a possibility to prevent QGIS from overwriting these font size settings? Thank you very much.<br>
</blockquote><div><br></div><div>If you are developing your plugin for QGIS 2.0+, there is now an option to set the font family and size used in the application under Options>>General dialog. This font is set using Qt stylesheets [0]. I believe this was also the case with QGIS 1.8, but the font was the default for the platform and not easily changeable. There is currently no documentation about this in the PyQGIS Cookbook, but basically you can try these two following approaches:<br>
<br></div><div>* Any widget that is a child of the main application or one of its widgets (e.g. iface or app's QMainWindow) will inherit the font set in Options. To override, set a custom stylesheet for your widgets or their components. Try to avoid wildcard assignment of styles, i.e. " * { color: #fff; } " OR " color:#fff; ", as this will cause the widget to not use the host window server's applied style and you will then have to style most aspects of the widget starting with a Qt-style default.<br>
<br></div><div>Instead, use something like " QLabel { color: #fff; } " or one of the other non-wildcard (aka non-universal) Qt stylesheet selectors [1]. You can set the stylesheet in Qt Designer or in the .ui editor in Qt Creator.<br>
<br></div><div>When working with font sizes, opt to honor the user's chosen app font setting, i.e. just like styling with CSS define the sizes using em or ex units so they are relative to the app font [2]. This will ensure the sizing works across most platforms and differing screen resolutions.<br>
</div><div><br></div><div>* Don't set the parent for your widget. This will most likely cause the widget to *not* inherit the app's stylesheet. (This is probably why your dialogs were not having their style overridden, if you didn't set a parent.) However, it is generally best practice to assign a parent to a widget, so I would avoid this approach and go with local stylesheet overrides as noted above.<br>
<br></div><div>NOTE: stylesheets generally override any similarly set Qt widget style properties.<br></div><div><br>[0] <a href="http://qt-project.org/doc/qt-4.7/stylesheet.html" target="_blank">http://qt-project.org/doc/qt-4.7/stylesheet.html</a><br>
[1] <a href="http://qt-project.org/doc/qt-4.7/stylesheet-syntax.html" target="_blank">http://qt-project.org/doc/qt-4.7/stylesheet-syntax.html</a><br>[2] <a href="http://qt-project.org/doc/qt-4.7/stylesheet-reference.html#id-55cf595e-a426-464c-9813-8cc49d142046" target="_blank">http://qt-project.org/doc/qt-4.7/stylesheet-reference.html#id-55cf595e-a426-464c-9813-8cc49d142046</a><br>
<br></div><div>Regards,<br><br>Larry<br><br></div><div> </div><blockquote class="ecxgmail_quote" style="border-left:1px solid rgb(204,204,204);padding-left:1ex;">
Josua<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br></div></div></div></div></div>                                     </div></body>
</html>