feat:添加一个自定义风格的类
class:ExCustomStyle的类,但是里面是空白的,为后面更新的控件风格作为一个基准
This commit is contained in:
parent
a1e7d4f3f7
commit
054148433a
6
QtCustomStyleEx/ExCustomStyle.cpp
Normal file
6
QtCustomStyleEx/ExCustomStyle.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "ExCustomStyle.h"
|
||||
|
||||
ExCustomStyle::ExCustomStyle()
|
||||
{
|
||||
|
||||
}
|
14
QtCustomStyleEx/ExCustomStyle.h
Normal file
14
QtCustomStyleEx/ExCustomStyle.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef EXCUSTOMSTYLE_H
|
||||
#define EXCUSTOMSTYLE_H
|
||||
|
||||
#include <QCommonStyle>
|
||||
|
||||
class ExCustomStyle : public QCommonStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExCustomStyle();
|
||||
};
|
||||
|
||||
#endif // EXCUSTOMSTYLE_H
|
@ -1,20 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Examples</class>
|
||||
<widget class="QWidget" name="Examples" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="Examples">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>1235</width>
|
||||
<height>695</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<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>
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user