feat:添加一个自定义风格的类

class:ExCustomStyle的类,但是里面是空白的,为后面更新的控件风格作为一个基准
This commit is contained in:
touwoyimuli 2019-08-26 21:23:26 +08:00
parent a1e7d4f3f7
commit 054148433a
5 changed files with 202 additions and 9 deletions

View File

@ -0,0 +1,6 @@
#include "ExCustomStyle.h"
ExCustomStyle::ExCustomStyle()
{
}

View File

@ -0,0 +1,14 @@
#ifndef EXCUSTOMSTYLE_H
#define EXCUSTOMSTYLE_H
#include <QCommonStyle>
class ExCustomStyle : public QCommonStyle
{
Q_OBJECT
public:
ExCustomStyle();
};
#endif // EXCUSTOMSTYLE_H

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Examples</class>
<widget class="QWidget" name="Examples">
@ -5,16 +6,173 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>1235</width>
<height>695</height>
</rect>
</property>
<property name="windowTitle">
<string>Examples</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>滚动条</string>
</attribute>
<widget class="QScrollBar" name="scrollBarHor">
<property name="geometry">
<rect>
<x>30</x>
<y>280</y>
<width>531</width>
<height>31</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<widget class="QScrollBar" name="scrollBarVer">
<property name="geometry">
<rect>
<x>540</x>
<y>40</y>
<width>31</width>
<height>191</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>431</width>
<height>161</height>
</rect>
</property>
<row>
<property name="text">
<string>a</string>
</property>
</row>
<row>
<property name="text">
<string>b</string>
</property>
</row>
<row>
<property name="text">
<string>c</string>
</property>
</row>
<row>
<property name="text">
<string>d</string>
</property>
</row>
<row>
<property name="text">
<string>e</string>
</property>
</row>
<row>
<property name="text">
<string>f</string>
</property>
</row>
<column>
<property name="text">
<string>1</string>
</property>
</column>
<column>
<property name="text">
<string>2</string>
</property>
</column>
<column>
<property name="text">
<string>3</string>
</property>
</column>
<column>
<property name="text">
<string>4</string>
</property>
</column>
<column>
<property name="text">
<string>5</string>
</property>
</column>
<column>
<property name="text">
<string>6</string>
</property>
</column>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>650</x>
<y>40</y>
<width>131</width>
<height>22</height>
</rect>
</property>
<item>
<property name="text">
<string>Windows</string>
</property>
</item>
<item>
<property name="text">
<string>New Item</string>
</property>
</item>
<item>
<property name="text">
<string>WindowsXP</string>
</property>
</item>
<item>
<property name="text">
<string>WindowsVista</string>
</property>
</item>
<item>
<property name="text">
<string>Fusion</string>
</property>
</item>
<item>
<property name="text">
<string>ExCustomStyle</string>
</property>
</item>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -26,10 +26,12 @@ CONFIG += c++11
SOURCES += \
main.cpp \
Examples.cpp
Examples.cpp \
ExCustomStyle.cpp
HEADERS += \
Examples.h
Examples.h \
ExCustomStyle.h
FORMS += \
Examples.ui

View File

@ -1,9 +1,22 @@
#include "Examples.h"
#include <QApplication>
#include <QStyleFactory>
#include <QDebug>
#include "ExCustomStyle.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//使用系统或者自定义的风格
// QStringList listStyle = QStyleFactory::keys();
// foreach(QString val, listStyle)
// qDebug()<<val<<" ";
// QStyleFactory::create("Fusion");
// ExCustomStyle* customStyle = new ExCustomStyle;
// qApp->setStyle(customStyle);
Examples w;
w.show();