Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would simply use a Style Sheet for the whole window.</p> <p>For instance, if your window is inheriting from QWidget, here is what I'm doing :</p> <pre><code>MainWindow::MainWindow(QWidget *parent) : QWidget(parent), ui(new Ui::MainWindow) { ui-&gt;setupUi(this); this-&gt;setStyleSheet("background-color: black;"); } </code></pre> <p>On my Mac, my whole application window is black (except the title bar).</p> <p>EDIT : according to comment, here is a solution without using ui files and loading an external style sheet</p> <pre><code>#include &lt;QtGui/QApplication&gt; #include &lt;QtGui/QMainWindow&gt; #include &lt;QtGui/QVBoxLayout&gt; #include &lt;QtGui/QPushButton&gt; #include &lt;QtCore/QFile&gt; int main(int ArgC, char* ArgV[]) { QApplication MyApp(ArgC, ArgV); QMainWindow* pWindow = new QMainWindow; QVBoxLayout* pLayout = new QVBoxLayout(pWindow); pWindow-&gt;setLayout(pLayout); QPushButton* pButton = new QPushButton("Test", pWindow); pLayout-&gt;addWidget(pButton); QFile file(":/qss/default.qss"); file.open(QFile::ReadOnly); QString styleSheet = QLatin1String(file.readAll()); qApp-&gt;setStyleSheet(styleSheet); pWindow-&gt;setVisible(true); MyApp.exec(); } </code></pre> <p>The style sheet file (default.qss) is as follow :</p> <pre><code>QWidget { background-color: black; } </code></pre> <p>This file is part of a resource file (stylesheet.qrc) :</p> <pre><code>&lt;RCC&gt; &lt;qresource prefix="/qss"&gt; &lt;file&gt;default.qss&lt;/file&gt; &lt;/qresource&gt; &lt;/RCC&gt; </code></pre> <p>And here is my project file :</p> <pre><code>TARGET = StyleSheet TEMPLATE = app SOURCES += main.cpp RESOURCES += stylesheet.qrc </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload