2018-02-20 11:26:06 -03:00
# QDarkStylesheet
2013-03-10 15:32:24 +01:00
2014-01-02 16:30:44 +01:00
[](https://travis-ci.org/ColinDuquesnoy/QDarkStyleSheet)
2015-05-28 19:46:58 +02:00
[](https://pypi.python.org/pypi/QDarkStyle)
2018-02-22 10:55:33 -03:00
[](https://opensource.org/licenses/MIT)
2018-02-20 11:26:06 -03:00
[](https://creativecommons.org/licenses/by/4.0/)
2018-03-13 11:46:39 +01:00
[](http://contributor-covenant.org/version/1/4/)
2018-02-22 10:55:33 -03:00
2014-01-02 16:20:29 +01:00
2018-02-05 23:44:26 -02:00
A dark stylesheet for Qt applications (Qt4, Qt5, PySide, PyQt4, PyQt5, QtPy,
PyQtGraph).
2013-03-10 17:59:50 +01:00
2018-02-20 11:26:06 -03:00
## Installation
2013-03-10 17:59:50 +01:00
2018-02-20 11:26:06 -03:00
### Python
2013-03-10 17:59:50 +01:00
2018-02-20 11:26:06 -03:00
From PyPI: Get the lastest stable version of ``qdarkstyle` ` package
using *pip* (preferable):
2013-03-10 17:59:50 +01:00
```bash
2018-02-05 23:44:26 -02:00
pip install qdarkstyle
2013-03-10 17:59:50 +01:00
```
2014-01-02 16:25:15 +01:00
2018-02-05 23:44:26 -02:00
From code: Download/clone the project, go to ``qdarkstyle` ` folder then:
- You can use the *setup* script and pip install.
```bash
pip install .
```
- Or, you can use the *setup* script with Python:
```bash
python setup.py install
```
2018-02-20 11:26:06 -03:00
### C++
2013-03-10 17:59:50 +01:00
2018-02-20 11:26:06 -03:00
- Download/clone the project and copy the following files to your application
directory (keep the existing directory hierarchy):
2014-01-29 17:52:23 +01:00
2018-02-20 11:26:06 -03:00
- **qdarkstyle/style.qss**
- **qdarkstyle/style.qrc**
- **qdarkstyle/rc/** (the whole directory)
2014-01-29 17:52:23 +01:00
2018-04-17 15:00:35 -03:00
- Add **qdarkstyle/style.qrc** to your ** .pro file** as follows:
2014-01-29 17:52:23 +01:00
2018-04-17 15:00:35 -03:00
```cpp
RESOURCES += qdarkstyle/style.qrc
```
2018-02-20 11:26:06 -03:00
- Load the stylesheet:
2014-01-02 16:25:15 +01:00
2018-02-20 11:26:06 -03:00
```cpp
2018-03-13 11:37:17 +01:00
QFile f(":qdarkstyle/style.qss");
2018-02-20 11:26:06 -03:00
if (!f.exists())
{
printf("Unable to set stylesheet, file not found\n");
}
else
{
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
2018-02-20 21:09:30 -03:00
}
2018-02-20 11:26:06 -03:00
```
2012-08-23 05:30:23 -07:00
2018-03-26 17:20:36 -03:00
_Note: The ":" in the file name is necessary to define that file as a resource library. For more information see the discussion [here ](https://github.com/ColinDuquesnoy/QDarkStyleSheet/pull/87 )._
2018-02-20 11:26:06 -03:00
## Usage
2012-08-23 15:03:05 +02:00
2018-02-20 11:26:06 -03:00
Here is an example using PySide
2012-08-23 15:03:05 +02:00
2012-11-05 19:42:35 +01:00
```Python
2013-03-10 15:23:21 +01:00
import sys
2013-03-10 17:59:50 +01:00
import qdarkstyle
2013-03-10 15:23:21 +01:00
from PySide import QtGui
2013-03-10 17:59:50 +01:00
2013-03-10 15:23:21 +01:00
# create the application and the main window
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
# setup stylesheet
2018-01-22 20:25:39 -02:00
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside())
2013-03-10 15:23:21 +01:00
# run
window.show()
app.exec_()
2012-11-05 19:42:35 +01:00
```
2012-08-23 15:03:05 +02:00
2018-02-05 23:44:26 -02:00
To use another wrapper for Qt, you just need to replace some lines.
See examples bellow.
2018-01-22 20:25:39 -02:00
2018-02-20 11:26:06 -03:00
To use PyQt4, change two lines
2014-01-02 16:20:29 +01:00
```Python
2018-01-22 20:25:39 -02:00
from PySide import QtGui
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt())
2014-01-02 16:20:29 +01:00
```
2018-02-05 23:44:26 -02:00
If PyQt5, more lines need to be changed because of its API,
see the complete example
2014-01-02 16:20:29 +01:00
```Python
2018-01-22 20:25:39 -02:00
import sys
import qdarkstyle
from PyQt5 import QtWidgets
2013-03-10 17:59:50 +01:00
2018-01-22 20:25:39 -02:00
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# run
window.show()
app.exec_()
2015-06-26 14:36:20 +02:00
```
2018-02-05 23:44:26 -02:00
If your project uses QtPy or you need to set it programmatically,
2018-02-20 11:26:06 -03:00
it is far more simple
2015-06-26 14:36:20 +02:00
2017-05-02 00:13:06 -03:00
```Python
2018-01-22 20:25:39 -02:00
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to pyqt, pyqt5, pyside or pyside2 (not implemented yet)
# you do not need to use QtPy to set this variable
os.environ['QT_API'] = 'pyqt'
# import from QtPy instead of doing it directly
# note that QtPy always uses PyQt5 API
from qtpy import QtWidgets
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet_from_environment())
# run
window.show()
app.exec_()
2015-06-26 14:36:20 +02:00
```
2018-02-20 11:26:06 -03:00
It is also simple if you use PyQtGraph
2014-05-17 20:41:39 +02:00
2017-05-02 00:13:06 -03:00
```Python
2018-01-22 20:25:39 -02:00
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to PyQt, PyQt5, PySide or PySide2 (not implemented yet)
2018-02-20 11:26:06 -03:00
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt'
2018-01-22 20:25:39 -02:00
# import from pyqtgraph instead of doing it directly
# note that PyQtGraph always uses PyQt4 API
from pyqtgraph.Qt import QtGui
# create the application and the main window
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True))
# run
window.show()
app.exec_()
2017-05-02 00:13:06 -03:00
```
2014-05-17 20:41:39 +02:00
_There is an example included in the *example* folder.
You can run the script without installing qdarkstyle. You only need to have
PySide (or PyQt4 or PyQt5) installed on your system._
2013-03-10 17:59:50 +01:00
2018-02-20 11:26:06 -03:00
## Snapshots
2013-03-10 15:32:04 +01:00
2018-02-06 12:17:25 -02:00
Here are a few snapshots comparing the use of QDarkStyle and the default style.
Click in the image to zoom.
< table style = "width:100%" >
< tr >
< th colspan = 2 > Containers (no tabs) and Buttons< / th >
< / tr >
< tr >
< td > < img src = "./screenshots/qdarkstyle_containers_buttons.png" / > < / td >
< td > < img src = "./screenshots/no_dark_containers_buttons.png" / > < / td >
< / tr >
< tr >
< th colspan = 2 > Containers (tabs) and Displays< / th >
< / tr >
< tr >
< td > < img src = "./screenshots/qdarkstyle_containers_tabs_displays.png" / > < / td >
< td > < img src = "./screenshots/no_dark_containers_tabs_displays.png" / > < / td >
< / tr >
< tr >
< th colspan = 2 > Widgets and Inputs (with fields)< / th >
< / tr >
< tr >
< td > < img src = "./screenshots/qdarkstyle_widgets_inputs_fields.png" / > < / td >
< td > < img src = "./screenshots/no_dark_widgets_inputs_fields.png" / > < / td >
< / tr >
< tr >
< th colspan = 2 > Views and Inputs (without fields)< / th >
< / tr >
< tr >
< td > < img src = "./screenshots/qdarkstyle_views_inputs_no_fields.png" / > < / td >
< td > < img src = "./screenshots/no_dark_views_inputs_no_fields.png" / > < / td >
< / tr >
< / table >
2018-02-05 23:44:26 -02:00
2018-02-20 11:26:06 -03:00
## Changelog
2018-02-05 23:44:26 -02:00
Please, see [CHANGES ](CHANGES.md ) file.
2018-02-20 11:26:06 -03:00
## License
2018-02-05 23:44:26 -02:00
This project is licensed under the MIT license.
Imagens contained in this project are licensed under CC-BY license.
For more information see [LICENSE ](LICENSE.md ) file.
2018-02-20 11:26:06 -03:00
## Authors
2018-02-05 23:44:26 -02:00
For more information see [AUTHORS ](AUTHORS.md ) file.
2018-02-20 11:26:06 -03:00
## Contribute
2018-02-05 23:44:26 -02:00
Most widgets have been styled. If you find a widget that has not been
style, just open an issue on the issue tracker or, better, submit a pull
request.
2018-02-20 17:01:58 -03:00
2018-02-22 10:55:33 -03:00
If you want to contribute, see [CONTRIBUTING ](CONTRIBUTING.md ) file.