彻底改版2.0

This commit is contained in:
feiyangqingyun
2021-11-17 16:41:30 +08:00
parent a7f4347959
commit ebfd531a91
2622 changed files with 8915 additions and 7263 deletions

View File

@@ -0,0 +1,8 @@
FORMS += \
$$PWD/frmmain.ui
HEADERS += \
$$PWD/frmmain.h
SOURCES += \
$$PWD/frmmain.cpp

View File

@@ -0,0 +1,61 @@
#pragma execution_character_set("utf-8")
#include "frmmain.h"
#include "ui_frmmain.h"
#include "iconhelper.h"
frmMain::frmMain(QWidget *parent) : QWidget(parent), ui(new Ui::frmMain)
{
ui->setupUi(this);
this->initForm();
}
frmMain::~frmMain()
{
delete ui;
}
void frmMain::initForm()
{
this->setWindowTitle("metro风格主界面");
int iconSize = 50;
int iconWidth = 100;
int iconHeight = 80;
QList<QString> listColorBg;
listColorBg << "#FF3739" << "#1A9FE0" << "#41BB1A" << "#1570A5" << "#FE781F" << "#9B59BB";
QList<QString> listColorText;
listColorText << "#FEFEFE" << "#FEFEFE" << "#FEFEFE" << "#FEFEFE" << "#FEFEFE" << "#FEFEFE";
QList<int> icons;
icons << 0xf2ba << 0xf002 << 0xf2c2 << 0xf02f << 0xf013 << 0xf021;
QList<QString> names;
names << "访客登记" << "记录查询" << "证件扫描" << "信息打印" << "系统设置" << "系统重启";
QList<QToolButton *> btns = this->findChildren<QToolButton *>();
for (int i = 0; i < btns.count(); i++) {
QToolButton *btn = btns.at(i);
btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
btn->setIconSize(QSize(iconWidth, iconHeight));
QPixmap pix = IconHelper::getPixmap(listColorText.at(i), icons.at(i), iconSize, iconWidth, iconHeight);
btn->setIcon(QIcon(pix));
btn->setText(names.at(i));
btn->setStyleSheet(QString("QToolButton{font:%1pt;color:%2;background-color:%3;border:none;border-radius:0px;}")
.arg(iconSize / 2).arg(listColorText.at(i)).arg(listColorBg.at(i)));
connect(btn, SIGNAL(clicked(bool)), this, SLOT(buttonClicked()));
}
}
void frmMain::buttonClicked()
{
QToolButton *btn = (QToolButton *)sender();
QString text = btn->text();
qDebug() << text;
if (text == "系统重启") {
close();
}
}

View File

@@ -0,0 +1,26 @@
#ifndef FRMMAIN_H
#define FRMMAIN_H
#include <QWidget>
namespace Ui {
class frmMain;
}
class frmMain : public QWidget
{
Q_OBJECT
public:
explicit frmMain(QWidget *parent = 0);
~frmMain();
private:
Ui::frmMain *ui;
private slots:
void initForm();
void buttonClicked();
};
#endif // FRMMAIN_H

135
ui/uidemo10/form/frmmain.ui Normal file
View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>frmMain</class>
<widget class="QWidget" name="frmMain">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<height>342</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QToolButton" name="btn1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="btn2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="btn3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="btn4">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="btn5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="btn6">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

12
ui/uidemo10/head.h Normal file
View File

@@ -0,0 +1,12 @@
#include <QtCore>
#include <QtGui>
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
#include <QtWidgets>
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
#include <QtCore5Compat>
#endif
#pragma execution_character_set("utf-8")

23
ui/uidemo10/main.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "frmmain.h"
#include "appinit.h"
#include "quihelper.h"
int main(int argc, char *argv[])
{
//设置不应用操作系统设置比如字体
QApplication::setDesktopSettingsAware(false);
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
#endif
QApplication a(argc, argv);
AppInit::Instance()->start();
QUIHelper::setFont();
QUIHelper::setCode();
frmMain w;
QUIHelper::setFormInCenter(&w);
w.show();
return a.exec();
}

16
ui/uidemo10/uidemo10.pro Normal file
View File

@@ -0,0 +1,16 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
TARGET = uidemo10
TEMPLATE = app
HEADERS += head.h
SOURCES += main.cpp
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/form
include ($$PWD/form/form.pri)
INCLUDEPATH += $$PWD/../core_common
include ($$PWD/../core_common/core_common.pri)