Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 5241

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- stylesheet.qdoc -->
  <title>Qt Style Sheets | Qt Widgets 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td >Qt Style Sheets</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="style-reference.html" />
  <link rel="next" href="stylesheet-syntax.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="style-reference.html">Styles</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="stylesheet-syntax.html">The Style Sheet Syntax</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#overview">Overview</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Style Sheets</h1>
<span class="subtitle"></span>
<!-- $$$stylesheet.html-description -->
<div class="descr"> <a name="details"></a>
<p>Qt Style Sheets are a powerful mechanism that allows you to customize the appearance of widgets, in addition to what is already possible by subclassing <a href="qstyle.html">QStyle</a>. The concepts, terminology, and syntax of Qt Style Sheets are heavily inspired by HTML <a href="http://www.w3.org/Style/CSS/">Cascading Style Sheets (CSS)</a> but adapted to the world of widgets.</p>
<p>Topics:</p>
<ul>
<li><a href="stylesheet.html#overview">Overview</a></li>
<li><a href="stylesheet-syntax.html">The Style Sheet Syntax</a></li>
<li><a href="stylesheet-designer.html">Qt Designer Integration</a></li>
<li><a href="stylesheet-customizing.html">Customizing Qt Widgets Using Style Sheets</a></li>
<li><a href="stylesheet-reference.html">Qt Style Sheets Reference</a></li>
<li><a href="stylesheet-examples.html">Qt Style Sheets Examples</a></li>
</ul>
<a name="overview"></a><a name="overview"></a>
<h2 id="overview">Overview</h2>
<p>Styles sheets are textual specifications that can be set on the whole application using <a href="qapplication.html#styleSheet-prop">QApplication::setStyleSheet</a>() or on a specific widget (and its children) using <a href="qwidget.html#styleSheet-prop">QWidget::setStyleSheet</a>(). If several style sheets are set at different levels, Qt derives the effective style sheet from all of those that are set. This is called cascading.</p>
<p>For example, the following style sheet specifies that all <a href="qlineedit.html">QLineEdit</a>s should use yellow as their background color, and all <a href="qcheckbox.html">QCheckBox</a>es should use red as the text color:</p>
<pre class="cpp">

  <span class="type"><a href="qlineedit.html">QLineEdit</a></span> { background: yellow }
  <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> { color: red }

</pre>
<p>For this kind of customization, style sheets are much more powerful than <a href="../qtgui/qpalette.html">QPalette</a>. For example, it might be tempting to set the <a href="../qtgui/qpalette.html#ColorRole-enum">QPalette::Button</a> role to red for a <a href="qpushbutton.html">QPushButton</a> to obtain a red push button. However, this wasn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and (on Windows and macOS) by the native theme engine.</p>
<p>Style sheets let you perform all kinds of customizations that are difficult or impossible to perform using <a href="../qtgui/qpalette.html">QPalette</a> alone. If you want yellow backgrounds for mandatory fields, red text for potentially destructive push buttons, or fancy check boxes, style sheets are the answer.</p>
<p>Style sheets are applied on top of the current <a href="qstyle.html">widget style</a>, meaning that your applications will look as native as possible, but any style sheet constraints will be taken into consideration. Unlike palette fiddling, style sheets offer guarantees: If you set the background color of a <a href="qpushbutton.html">QPushButton</a> to be red, you can be assured that the button will have a red background in all styles, on all platforms. In addition, Qt Designer provides style sheet integration, making it easy to view the effects of a style sheet in different <a href="qstyle.html">widget styles</a>.</p>
<p>In addition, style sheets can be used to provide a distinctive look and feel for your application, without having to subclass <a href="qstyle.html">QStyle</a>. For example, you can specify arbitrary images for radio buttons and check boxes to make them stand out. Using this technique, you can also achieve minor customizations that would normally require subclassing several style classes, such as specifying a <a href="qstyle.html#styleHint">style hint</a>. The <a href="qtwidgets-widgets-stylesheet-example.html">Style Sheet</a> example depicted below defines two distinctive style sheets that you can try out and modify at will.</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/stylesheet-pagefold.png" alt="" /></td></tr>
<tr valign="top" class="even"><td >Pagefold theme running on Windows</td></tr>
</table></div>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/stylesheet-coffee-cleanlooks.png" alt="" /></td><td ><img src="images/stylesheet-pagefold-mac.png" alt="" /></td></tr>
<tr valign="top" class="even"><td >Coffee theme running on Ubuntu Linux</td><td >Pagefold theme running on macOS</td></tr>
</table></div>
<p>When a style sheet is active, the <a href="qstyle.html">QStyle</a> returned by <a href="qwidget.html#style">QWidget::style</a>() is a wrapper &quot;style sheet&quot; style, <i>not</i> the platform-specific style. The wrapper style ensures that any active style sheet is respected and otherwise forwards the drawing operations to the underlying, platform-specific style (e.g&#x2e;, QWindowsVistaStyle on Windows).</p>
<p>Since Qt 4.5, Qt style sheets fully supports macOS.</p>
</div>
<!-- @@@stylesheet.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="style-reference.html">Styles</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="stylesheet-syntax.html">The Style Sheet Syntax</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>