1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

move some QQT to QQt, delete some ui, add some svgwidgets

This commit is contained in:
tianduanrui 2017-11-16 22:09:17 +08:00
parent 782a7e8340
commit fd8bc21674
46 changed files with 508 additions and 413 deletions

View File

@ -20,7 +20,10 @@ SUBDIRS = src/qqt.pro
#SUBDIRS += examples/exquisite
#can't support ios
#SUBDIRS += examples/qqtprintsupportexample
#
SUBDIRS += examples/tabwidgetexamples
#
SUBDIRS += examples/svgtest
#-----------------------------------------------------------------
#need vlcQt libvlc library

11
examples/svgtest/main.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,24 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qqtsvgwidget.h"
#include "qqtsvgpushbutton.h"
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QString svg = QString("/Users/abel/Pictures/jia.svg");
ui->w->setSvgFile(svg);
ui->b0->iconTable()[BTN_NORMAL] = "/Users/abel/Develop/d1-product/App/skin/default/bt_stir.svg";
ui->b0->iconTable()[BTN_HOVER] = "/Users/abel/Develop/d1-product/App/skin/default/bt_stir.svg";
ui->b0->iconTable()[BTN_PRESS] = "/Users/abel/Develop/d1-product/App/skin/default/bt_stir_press.svg";
ui->b0->renderToVariable();
}
MainWindow::~MainWindow()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>782</width>
<height>282</height>
</rect>
</property>
<attribute name="label">
<string>Page 1</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QQtSvgWidget" name="w" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>782</width>
<height>282</height>
</rect>
</property>
<attribute name="label">
<string>Page 2</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QQtSvgPushButton" name="b0">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<attribute name="label">
<string>Page 3</string>
</attribute>
</widget>
<widget class="QWidget" name="page_4">
<attribute name="label">
<string>Page 4</string>
</attribute>
</widget>
<widget class="QWidget" name="page_5">
<attribute name="label">
<string>Page 5</string>
</attribute>
</widget>
<widget class="QWidget" name="page_6">
<attribute name="label">
<string>Page 6</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QQtSvgWidget</class>
<extends>QWidget</extends>
<header>qqtsvgwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QQtSvgPushButton</class>
<extends>QPushButton</extends>
<header>qqtsvgpushbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,80 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-11-16T19:08:13
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = svgtest
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
CONFIG += mobility
MOBILITY =
#-------------------------------------------------
#link qqt library
#if you link a library to your app, on android you must select the running kit to the app, not LibQQt e.g.
#-------------------------------------------------
include(../qqtframe2/link_qqt_library.pri)
#-------------------------------------------------
#install
#-------------------------------------------------
#CONFIG += can_install
can_install:equals(QKIT_PRIVATE, EMBEDDED) {
target.path = /Application
INSTALLS += target
} else: unix {
equals(QKIT_PRIVATE, macOS) {
target.path = /Applications
INSTALLS += target
}
}
#-------------------------------------------------
##project environ
#-------------------------------------------------
#default
message ($${TARGET} config $${CONFIG})
message ($${TARGET} define $${DEFINES})
contains(QKIT_PRIVATE, ANDROID|ANDROIDX86) {
CONFIG += mobility
MOBILITY =
DISTFILES += \
android/AndroidManifest.xml \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradlew \
android/res/values/libs.xml \
android/build.gradle \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew.bat
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
}

View File

@ -472,7 +472,7 @@
<number>2</number>
</property>
<item>
<widget class="QQTCheckBox" name="checkShift">
<widget class="QQtCheckBox" name="checkShift">
<property name="text">
<string/>
</property>
@ -1033,7 +1033,7 @@
</widget>
</item>
<item>
<widget class="QQTPushButton" name="btnDelete">
<widget class="QQtPushButton" name="btnDelete">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
@ -1265,7 +1265,7 @@
</widget>
</item>
<item>
<widget class="QQTPushButton" name="btnDel">
<widget class="QQtPushButton" name="btnDel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
@ -1779,28 +1779,28 @@
<number>2</number>
</property>
<item>
<widget class="QQTRadioButton" name="radioCN">
<widget class="QQtRadioButton" name="radioCN">
<property name="text">
<string>中文</string>
</property>
</widget>
</item>
<item>
<widget class="QQTRadioButton" name="radioEN">
<widget class="QQtRadioButton" name="radioEN">
<property name="text">
<string>英文</string>
</property>
</widget>
</item>
<item>
<widget class="QQTRadioButton" name="radioNum">
<widget class="QQtRadioButton" name="radioNum">
<property name="text">
<string>123</string>
</property>
</widget>
</item>
<item>
<widget class="QQTPushButton" name="btnSpace">
<widget class="QQtPushButton" name="btnSpace">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Ignored">
<horstretch>0</horstretch>
@ -1816,7 +1816,7 @@
</widget>
</item>
<item>
<widget class="QQTPushButton" name="btnReturn">
<widget class="QQtPushButton" name="btnReturn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Ignored">
<horstretch>0</horstretch>
@ -1832,7 +1832,7 @@
</widget>
</item>
<item>
<widget class="QQTPushButton" name="btnClose">
<widget class="QQtPushButton" name="btnClose">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
@ -1857,17 +1857,17 @@
</widget>
<customwidgets>
<customwidget>
<class>QQTPushButton</class>
<class>QQtPushButton</class>
<extends>QPushButton</extends>
<header>qqtpushbutton.h</header>
</customwidget>
<customwidget>
<class>QQTRadioButton</class>
<class>QQtRadioButton</class>
<extends>QRadioButton</extends>
<header>qqtradiobutton.h</header>
</customwidget>
<customwidget>
<class>QQTCheckBox</class>
<class>QQtCheckBox</class>
<extends>QCheckBox</extends>
<header>qqtcheckbox.h</header>
</customwidget>

View File

@ -29,7 +29,7 @@
</item>
<item row="1" column="2">
<widget class="QWidget" name="widgetBottom" native="true">
<widget class="QQTPushButton" name="btnYes">
<widget class="QQtPushButton" name="btnYes">
<property name="geometry">
<rect>
<x>80</x>
@ -42,7 +42,7 @@
<string>Yes</string>
</property>
</widget>
<widget class="QQTPushButton" name="btnNo">
<widget class="QQtPushButton" name="btnNo">
<property name="geometry">
<rect>
<x>240</x>
@ -61,7 +61,7 @@
</widget>
<customwidgets>
<customwidget>
<class>QQTPushButton</class>
<class>QQtPushButton</class>
<extends>QPushButton</extends>
<header>qqtpushbutton.h</header>
</customwidget>

View File

@ -36,7 +36,7 @@
</rect>
</property>
</widget>
<widget class="QQTPushButton" name="pushButton_ssid_connect">
<widget class="QQtPushButton" name="pushButton_ssid_connect">
<property name="geometry">
<rect>
<x>270</x>
@ -78,7 +78,7 @@
</widget>
<customwidgets>
<customwidget>
<class>QQTPushButton</class>
<class>QQtPushButton</class>
<extends>QPushButton</extends>
<header>qqtpushbutton.h</header>
</customwidget>

View File

@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QQTPushButton" name="btnCancel">
<widget class="QQtPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>220</x>
@ -52,7 +52,7 @@
</widget>
<customwidgets>
<customwidget>
<class>QQTPushButton</class>
<class>QQtPushButton</class>
<extends>QPushButton</extends>
<header>qqtpushbutton.h</header>
</customwidget>

View File

@ -167,7 +167,11 @@ contains (DEFINES, __PRINTSUPPORT__) {
DEFINES += __EXQUISITE__
#if you use QR encode, open this annotation
DEFINES += __QRENCODE__
#if you use Svg widgets, open this annotation
DEFINES += __SVGWIDGETS__
contains (DEFINES, __SVGWIDGETS__) {
QT += svg
}
##################WebSocket Module###############################
#if you use QtSoap, open this annotation
DEFINES += __QTSOAP__
@ -239,3 +243,4 @@ INCLUDEPATH += $$PWD/exquisite
# c support
INCLUDEPATH += $$PWD/qrencode
INCLUDEPATH += $$PWD/soap
INCLUDEPATH += $$PWD/svgwidgets

View File

@ -12,8 +12,12 @@
#if you succeed with LibQQt, please thumb up.
#2017年11月10日18:53:56
#-------------------------------------------------
SOURCES +=
HEADERS +=
SOURCES += \
$$PWD/svgwidgets/qqtsvgwidget.cpp \
$$PWD/svgwidgets/qqtsvgpushbutton.cpp
HEADERS += \
$$PWD/svgwidgets/qqtsvgwidget.h \
$$PWD/svgwidgets/qqtsvgpushbutton.h
#root dir
HEADERS += $$PWD/qqt.h \
@ -111,17 +115,8 @@ HEADERS += \
$$PWD/widgets/qqtapplication.h \
$$PWD/widgets/qqtlabel.h
FORMS += \
$$PWD/widgets/qqtcheckbox.ui \
$$PWD/widgets/qqtlistview.ui \
$$PWD/widgets/qqtprogressbar.ui \
$$PWD/widgets/qqtpushbutton.ui \
$$PWD/widgets/qqtradiobutton.ui \
$$PWD/widgets/qqttableview.ui \
$$PWD/widgets/qqttreeview.ui \
$$PWD/widgets/qqtwidget.ui \
$$PWD/widgets/qqttablewidget.ui \
$$PWD/widgets/qqtmptablewidget.ui \
$$PWD/widgets/qqttreewidget.ui
$$PWD/widgets/qqtmptablewidget.ui

View File

@ -0,0 +1,30 @@
#include "qqtsvgpushbutton.h"
#include <QString>
QQtSvgPushButton::QQtSvgPushButton(QWidget* parent) : QQtPushButton(parent)
{
}
void QQtSvgPushButton::renderToVariable()
{
TBtnIconTable& pic = iconTable();
for (int i = 0; i < BTN_MAX; i++)
r[i].load(pic[i]);
}
void QQtSvgPushButton::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event)
QStylePainter p(this);
EBtnStatus bs = btnStatus();
r[bs].render(&p);
bool enabled = isEnabled();
QStyleOptionButton opt;
initStyleOption(&opt);
p.drawItemText(rect(), Qt::AlignCenter, opt.palette, enabled, text());
}

View File

@ -0,0 +1,34 @@
#ifndef QQTSVGPUSHBUTTON_H
#define QQTSVGPUSHBUTTON_H
#include <qqtpushbutton.h>
#include <QSvgRenderer>
#include <qqtwidgets.h>
class QQtSvgPushButton : public QQtPushButton
{
Q_OBJECT
public:
explicit QQtSvgPushButton(QWidget* parent = nullptr);
virtual ~QQtSvgPushButton() {}
/**
* @brief renderToVariable
* call this function after iconTable() set.
*/
void renderToVariable();
signals:
public slots:
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent* event) override;
private:
QSvgRenderer r[BTN_MAX];
};
#endif // QQTSVGPUSHBUTTON_H

View File

@ -0,0 +1,16 @@
#include "qqtsvgwidget.h"
QQtSvgWidget::QQtSvgWidget(QWidget* parent) : QSvgWidget(parent)
{
}
void QQtSvgWidget::setSvgFile(QString& filename)
{
return load(filename);
}
void QQtSvgWidget::setSvgContent(QByteArray& bytes)
{
return load(bytes);
}

View File

@ -0,0 +1,19 @@
#ifndef QQTSVGWIDGET_H
#define QQTSVGWIDGET_H
#include <QSvgWidget>
class QQtSvgWidget : public QSvgWidget
{
Q_OBJECT
public:
explicit QQtSvgWidget(QWidget* parent = nullptr);
void setSvgFile(QString& filename);
void setSvgContent(QByteArray& bytes);
signals:
public slots:
};
#endif // QQTSVGWIDGET_H

View File

@ -1,34 +1,30 @@
#include "qqtcheckbox.h"
#include "ui_qqtcheckbox.h"
#include <QStylePainter>
#include "qqtwidgets.h"
QQTCheckBox::QQTCheckBox(QWidget* parent) :
QCheckBox(parent),
ui(new Ui::QQTCheckBox)
QQtCheckBox::QQtCheckBox(QWidget* parent) :
QCheckBox(parent)
{
ui->setupUi(this);
}
QQTCheckBox::~QQTCheckBox()
QQtCheckBox::~QQtCheckBox()
{
delete ui;
}
void QQTCheckBox::pixMap(QImage& icon, QImage& iconSel)
void QQtCheckBox::pixMap(QImage& icon, QImage& iconSel)
{
icon = QImage(this->m_icon[BTN_NORMAL]);
iconSel = QImage(this->m_icon[BTN_PRESS]);
}
void QQTCheckBox::setPixmap(const QString& icon, const QString& iconSel)
void QQtCheckBox::setPixmap(const QString& icon, const QString& iconSel)
{
this->m_icon[BTN_NORMAL] = icon;
this->m_icon[BTN_PRESS] = iconSel;
}
void QQTCheckBox::paintEvent(QPaintEvent*)
void QQtCheckBox::paintEvent(QPaintEvent*)
{
QStylePainter p(this);
@ -43,7 +39,7 @@ void QQTCheckBox::paintEvent(QPaintEvent*)
p.drawItemText(rect(), Qt::AlignCenter, opt.palette, true, text());
}
bool QQTCheckBox::hitButton(const QPoint& pos) const
bool QQtCheckBox::hitButton(const QPoint& pos) const
{
Q_UNUSED(pos)
//TODO:

View File

@ -6,34 +6,30 @@
#include "qqtwidgets.h"
#include "qqt-local.h"
namespace Ui {
class QQTCheckBox;
}
/**
* @brief The QQTCheckBox class
* @brief The QQtCheckBox class
*
*/
class QQTSHARED_EXPORT QQTCheckBox : public QCheckBox
class QQTSHARED_EXPORT QQtCheckBox : public QCheckBox
{
Q_OBJECT
public:
explicit QQTCheckBox(QWidget *parent = 0);
~QQTCheckBox();
explicit QQtCheckBox(QWidget* parent = 0);
virtual ~QQtCheckBox();
void pixMap(QImage& m_icon, QImage& m_iconSel);
void setPixmap(const QString& m_icon = QString(), const QString &m_iconSel = QString());
void setPixmap(const QString& m_icon = QString(), const QString& m_iconSel = QString());
private:
Ui::QQTCheckBox *ui;
TBtnIconTable m_icon;
// QWidget interface
protected:
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent*);
// QAbstractButton interface
protected:
bool hitButton(const QPoint &pos) const;
bool hitButton(const QPoint& pos) const;
};
#endif // QQTCHECKBOX_H

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QQTCheckBox</class>
<widget class="QCheckBox" name="QQTCheckBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>149</width>
<height>43</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,14 +1,10 @@
#include "qqtlistview.h"
#include "ui_qqtlistview.h"
QQTListView::QQTListView(QWidget *parent) :
QListView(parent),
ui(new Ui::QQTListView)
QQtListView::QQtListView(QWidget* parent) :
QListView(parent)
{
ui->setupUi(this);
}
QQTListView::~QQTListView()
QQtListView::~QQtListView()
{
delete ui;
}

View File

@ -4,20 +4,15 @@
#include <QListView>
#include <qqt-local.h>
namespace Ui {
class QQTListView;
}
class QQTSHARED_EXPORT QQTListView : public QListView
class QQTSHARED_EXPORT QQtListView : public QListView
{
Q_OBJECT
public:
explicit QQTListView(QWidget *parent = 0);
~QQTListView();
explicit QQtListView(QWidget* parent = 0);
virtual ~QQtListView();
private:
Ui::QQTListView *ui;
};
#endif // QQTLISTVIEW_H

View File

@ -1,21 +0,0 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>QQTListView</class>
<widget class="QListView" name="QQTListView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View File

@ -99,7 +99,7 @@ void QQTMPTableWidget::query(QString filter)
for(int i = 0; i < pix; i++)
{
//ptime();//89ms
QQTTableWidget* page = new QQTTableWidget(this);
QQtTableWidget* page = new QQtTableWidget(this);
//ptime();//2ms
page->setDB(m_name);
//ptime();//8ms
@ -140,7 +140,7 @@ void QQTMPTableWidget::query(QString filter)
for(int i = 0; i < m_pageNum; i++)
{
QQTTableWidget* page = (QQTTableWidget*)(ui->stWidgetPage->widget(i));
QQtTableWidget* page = (QQtTableWidget*)(ui->stWidgetPage->widget(i));
page->query(QString("%1 limit %2 offset %3")
.arg(filter)
.arg(m_numPerPage)
@ -251,7 +251,7 @@ void QQTMPTableWidget::selectedRows(int column, QVector<QStringList> &strl)
{
for(int i = 0; i < m_pageNum; i++)
{
QQTTableWidget* page = (QQTTableWidget*)ui->stWidgetPage->widget(i);
QQtTableWidget* page = (QQtTableWidget*)ui->stWidgetPage->widget(i);
QMap<int, QStringList> ids;
page->selectedRows(column, ids);
QMapIterator<int, QStringList> itor(ids);
@ -263,7 +263,7 @@ void QQTMPTableWidget::selectedRows(int column, QVector<QStringList> &strl)
return;
}
QQTTableWidget* QQTMPTableWidget::selectedRows(int column)
QQtTableWidget* QQTMPTableWidget::selectedRows(int column)
{
QString sectionName;
QSqlQuery query(m_db);
@ -275,7 +275,7 @@ QQTTableWidget* QQTMPTableWidget::selectedRows(int column)
QVector<QStringList> lid;
selectedRows(column, lid);
static QQTTableWidget* page = new QQTTableWidget(this);
static QQtTableWidget* page = new QQtTableWidget(this);
page->setDB(m_name);
page->setTable(m_table);
@ -316,7 +316,7 @@ void QQTMPTableWidget::removeSelectedRows(int column)
{
for(int i = 0; i < m_pageNum; i++)
{
QQTTableWidget* page = (QQTTableWidget*)ui->stWidgetPage->widget(i);
QQtTableWidget* page = (QQtTableWidget*)ui->stWidgetPage->widget(i);
QMap<int, QStringList> ids;
page->selectedRows(column, ids);
page->removeRows(column, ids.values());

View File

@ -39,7 +39,7 @@ public:
void setColumnWidth(int column, int width);
void query(QString filter = "1=1");
void selectedRows(int column, QVector<QStringList> & strl);
QQTTableWidget* selectedRows(int column = 0);
QQtTableWidget* selectedRows(int column = 0);
int pageNum();
int currentPage();
void setCurrentPage(int page);

View File

@ -1,24 +1,20 @@
#include "qqtpushbutton.h"
#include "ui_qqtpushbutton.h"
#include <QStylePainter>
#include <QMouseEvent>
#include "qqtcore.h"
#include "qqtwidgets.h"
QQTPushButton::QQTPushButton(QWidget* parent) :
QPushButton(parent),
ui(new Ui::QQTPushButton)
QQtPushButton::QQtPushButton(QWidget* parent) :
QPushButton(parent)
{
ui->setupUi(this);
state = BTN_NORMAL;
ring = false;
}
QQTPushButton::~QQTPushButton()
QQtPushButton::~QQtPushButton()
{
delete ui;
}
void QQTPushButton::paintEvent(QPaintEvent* e)
void QQtPushButton::paintEvent(QPaintEvent* e)
{
Q_UNUSED(e)
QStylePainter p(this);
@ -50,18 +46,19 @@ void QQTPushButton::paintEvent(QPaintEvent* e)
p.drawItemText(rect(), Qt::AlignCenter, opt.palette, enabled, text());
}
void QQTPushButton::mousePressEvent(QMouseEvent* e)
void QQtPushButton::mousePressEvent(QMouseEvent* e)
{
if (e->button() == Qt::LeftButton)
{
state = BTN_PRESS;
QApplication::beep();
if (ring)
QApplication::beep();
//pline() << state;
}
QPushButton::mousePressEvent(e);
}
void QQTPushButton::mouseReleaseEvent(QMouseEvent* e)
void QQtPushButton::mouseReleaseEvent(QMouseEvent* e)
{
if (e->button() == Qt::LeftButton)
{
@ -79,24 +76,24 @@ void QQTPushButton::mouseReleaseEvent(QMouseEvent* e)
QPushButton::mouseReleaseEvent(e);
}
void QQTPushButton::enterEvent(QEvent* e)
void QQtPushButton::enterEvent(QEvent* e)
{
state = BTN_HOVER;
QPushButton::enterEvent(e);
}
void QQTPushButton::leaveEvent(QEvent* e)
void QQtPushButton::leaveEvent(QEvent* e)
{
state = BTN_NORMAL;
QPushButton::leaveEvent(e);
}
void QQTPushButton::changeEvent(QEvent* e)
void QQtPushButton::changeEvent(QEvent* e)
{
QPushButton::changeEvent(e);
}
void QQTPushButton::enabledChange(bool enabled)
void QQtPushButton::enabledChange(bool enabled)
{
state = isEnabled() ? BTN_NORMAL : BTN_DISABLE;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)

View File

@ -1,47 +1,45 @@
#ifndef QQTPushButton_H
#define QQTPushButton_H
#ifndef QQTPUSHBUTTON_H
#define QQTPUSHBUTTON_H
#include <QPushButton>
#include "qqtwidgets.h"
#include <qqt-local.h>
#include "qqtwidgets.h"
namespace Ui {
class QQTPushButton;
}
class QQTSHARED_EXPORT QQTPushButton : public QPushButton
class QQTSHARED_EXPORT QQtPushButton : public QPushButton
{
Q_OBJECT
public:
explicit QQTPushButton(QWidget *parent = 0);
~QQTPushButton();
explicit QQtPushButton(QWidget* parent = 0);
~QQtPushButton();
/*
* QQTPushButton [] =
* QQtPushButton [] =
*/
TBtnIconTable& iconTable() { return m_pixmap; }
inline TBtnIconTable& iconTable() { return m_pixmap; }
inline EBtnStatus btnStatus() const { return state; }
inline void setRing(bool op = false) { ring = op; }
private:
Ui::QQTPushButton *ui;
int state;
EBtnStatus state;
TBtnIconTable m_pixmap;
bool ring;
// QWidget interface
protected:
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent*);
// QWidget interface
protected:
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void changeEvent(QEvent *e);
void mousePressEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void enterEvent(QEvent*);
void leaveEvent(QEvent*);
void changeEvent(QEvent* e);
// QWidget interface
protected:
void enabledChange(bool);
};
#endif // QQTPushButton_H
#endif // QQTPUSHBUTTON_H

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QQTPushButton</class>
<widget class="QPushButton" name="QQTPushButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>58</width>
<height>27</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,32 +1,28 @@
#include "qqtradiobutton.h"
#include "ui_qqtradiobutton.h"
#include <QStylePainter>
QQTRadioButton::QQTRadioButton(QWidget* parent) :
QRadioButton(parent),
ui(new Ui::QQTRadioButton)
QQtRadioButton::QQtRadioButton(QWidget* parent) :
QRadioButton(parent)
{
ui->setupUi(this);
}
QQTRadioButton::~QQTRadioButton()
QQtRadioButton::~QQtRadioButton()
{
delete ui;
}
void QQTRadioButton::pixMap(QImage& icon, QImage& iconSel)
void QQtRadioButton::pixMap(QImage& icon, QImage& iconSel)
{
icon = QImage(this->m_icon[BTN_NORMAL]);
iconSel = QImage(this->m_icon[BTN_PRESS]);
}
void QQTRadioButton::setPixmap(const QString& icon, const QString& iconSel)
void QQtRadioButton::setPixmap(const QString& icon, const QString& iconSel)
{
this->m_icon[BTN_NORMAL] = icon;
this->m_icon[BTN_PRESS] = iconSel;
}
void QQTRadioButton::paintEvent(QPaintEvent*)
void QQtRadioButton::paintEvent(QPaintEvent*)
{
QStylePainter p(this);
QString icon = isChecked() ? m_icon[BTN_PRESS] : m_icon[BTN_NORMAL];
@ -47,7 +43,7 @@ void QQTRadioButton::paintEvent(QPaintEvent*)
}
bool QQTRadioButton::hitButton(const QPoint& pos) const
bool QQtRadioButton::hitButton(const QPoint& pos) const
{
Q_UNUSED(pos)
return true;

View File

@ -6,31 +6,26 @@
#include "qqtwidgets.h"
#include "qqt-local.h"
namespace Ui {
class QQTRadioButton;
}
class QQTSHARED_EXPORT QQTRadioButton : public QRadioButton
class QQTSHARED_EXPORT QQtRadioButton : public QRadioButton
{
Q_OBJECT
public:
explicit QQTRadioButton(QWidget *parent = 0);
~QQTRadioButton();
explicit QQtRadioButton(QWidget* parent = 0);
virtual ~QQtRadioButton();
void pixMap(QImage& m_icon, QImage& m_iconSel);
void setPixmap(const QString& m_icon = QString(), const QString &m_iconSel = QString());
void setPixmap(const QString& m_icon = QString(), const QString& m_iconSel = QString());
private:
Ui::QQTRadioButton *ui;
TBtnIconTable m_icon;
// QWidget interface
protected:
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent*);
// QAbstractButton interface
protected:
bool hitButton(const QPoint &pos) const;
bool hitButton(const QPoint& pos) const;
};
#endif // QQTRADIOBUTTON_H

View File

@ -1,21 +0,0 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>QQTRadioButton</class>
<widget name="QQTRadioButton" class="QWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View File

@ -1,15 +1,11 @@
#include "qqttableview.h"
#include "ui_qqttableview.h"
#include <QFile>
#include <QScrollBar>
#include <QSqlRelationalDelegate>
QQTTableView::QQTTableView(QWidget *parent) :
QTableView(parent),
ui(new Ui::QQTTableView)
QQtTableView::QQtTableView(QWidget* parent) :
QTableView(parent)
{
ui->setupUi(this);
m_header = new QQTHeaderView(Qt::Horizontal, this);
m_vheader = new QQTHeaderView(Qt::Vertical, this);
@ -27,22 +23,21 @@ QQTTableView::QQTTableView(QWidget *parent) :
}
QQTTableView::~QQTTableView()
QQtTableView::~QQtTableView()
{
delete ui;
}
void QQTTableView::setQQTHeader()
void QQtTableView::setQQTHeader()
{
setHorizontalHeader(m_header);
}
void QQTTableView::setQQTVHeader()
void QQtTableView::setQQTVHeader()
{
setVerticalHeader(m_vheader);
}
void QQTTableView::setObjectName(const QString &name)
void QQtTableView::setObjectName(const QString& name)
{
QTableView::setObjectName(name);
horizontalHeader()->setObjectName(QString("%1_Header").arg(name));

View File

@ -5,25 +5,20 @@
#include "qqtheaderview.h"
#include "qqt-local.h"
namespace Ui {
class QQTTableView;
}
class QQTSHARED_EXPORT QQTTableView : public QTableView
class QQTSHARED_EXPORT QQtTableView : public QTableView
{
Q_OBJECT
public:
explicit QQTTableView(QWidget *parent = 0);
~QQTTableView();
explicit QQtTableView(QWidget* parent = 0);
virtual ~QQtTableView();
QQTHeaderView* QQTHHeader() { return m_header; }
QQTHeaderView* QQTVHeader() { return m_vheader; }
void setQQTHeader();
void setQQTVHeader();
void setObjectName(const QString &name);
void setObjectName(const QString& name);
private:
Ui::QQTTableView *ui;
QQTHeaderView* m_vheader;
QQTHeaderView* m_header;

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QQTTableView</class>
<widget class="QTableView" name="QQTTableView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>458</width>
<height>211</height>
</rect>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,15 +1,11 @@
#include "qqttablewidget.h"
#include "ui_qqttablewidget.h"
#include "qqt-qt.h"
#include "qqtcore.h"
#include "qqtsql.h"
QQTTableWidget::QQTTableWidget(QWidget *parent) :
QQTTableView(parent),
ui(new Ui::QQTTableWidget)
QQtTableWidget::QQtTableWidget(QWidget* parent) :
QQtTableView(parent)
{
ui->setupUi(this);
m_db = newDatabaseConn();
m_model = new QQTTableModel(this, m_db);
setModel(m_model);
@ -19,14 +15,13 @@ QQTTableWidget::QQTTableWidget(QWidget *parent) :
setItemDelegate(new QSqlRelationalDelegate(this));
}
QQTTableWidget::~QQTTableWidget()
QQtTableWidget::~QQtTableWidget()
{
delete ui;
}
void QQTTableWidget::setDB(QString db)
void QQtTableWidget::setDB(QString db)
{
if(db.isEmpty())
if (db.isEmpty())
{
//TODO:
closeDatabase(m_db);
@ -36,34 +31,34 @@ void QQTTableWidget::setDB(QString db)
setDatabaseName(m_db, db);
}
void QQTTableWidget::setTable(QString table)
void QQtTableWidget::setTable(QString table)
{
m_model->setTable(table);
}
void QQTTableWidget::query(QString excp)
void QQtTableWidget::query(QString excp)
{
m_model->query(excp);
}
void QQTTableWidget::removeRow(int row)
void QQtTableWidget::removeRow(int row)
{
m_model->removeRow(row);
m_model->submit();
}
void QQTTableWidget::removeRows(int column, QList<QStringList> ids)
void QQtTableWidget::removeRows(int column, QList<QStringList> ids)
{
int rowCount = m_model->rowCount();
int i = 0;
while(i < rowCount)
while (i < rowCount)
{
QModelIndex idx = m_model->index(i, column);
/*
* rowCount后的index无效
*/
if(!idx.isValid())
if (!idx.isValid())
break;
QString modelColValue = m_model->data(idx).toString();
@ -72,11 +67,11 @@ void QQTTableWidget::removeRows(int column, QList<QStringList> ids)
* ids中找到列值相等的row进行删除i不变
*/
QListIterator<QStringList> itor(ids);
while(itor.hasNext())
while (itor.hasNext())
{
QString colValue = itor.next().at(column);
if(colValue == modelColValue)
if (colValue == modelColValue)
{
removeRow(i); i--;
break;
@ -86,13 +81,14 @@ void QQTTableWidget::removeRows(int column, QList<QStringList> ids)
}
}
void QQTTableWidget::selectedRows(int column , QMap<int, QStringList> &ids)
void QQtTableWidget::selectedRows(int column, QMap<int, QStringList>& ids)
{
QModelIndexList l = selectionModel()->selectedRows(column);
QModelIndex idx;
foreach (idx, l) {
foreach (idx, l)
{
QStringList l;
for(int i = 0; i < m_model->columnCount(); i++)
for (int i = 0; i < m_model->columnCount(); i++)
l << m_model->index(idx.row(), i).data().toString();
ids.insert(idx.row(), l);
}

View File

@ -5,17 +5,13 @@
#include "qqttablemodel.h"
#include "qqt-local.h"
namespace Ui {
class QQTTableWidget;
}
class QQTSHARED_EXPORT QQTTableWidget : public QQTTableView
class QQTSHARED_EXPORT QQtTableWidget : public QQtTableView
{
Q_OBJECT
public:
explicit QQTTableWidget(QWidget *parent = 0);
~QQTTableWidget();
explicit QQtTableWidget(QWidget* parent = 0);
virtual ~QQtTableWidget();
void setDB(QString db = "");
void setTable(QString table);
@ -33,7 +29,6 @@ public:
void selectedRows(int column, QMap<int, QStringList>& ids);
private:
Ui::QQTTableWidget *ui;
QQTTableModel* m_model;
QSqlDatabase m_db;
};

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QQTTableWidget</class>
<widget class="QQTTableView" name="QQTTableWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>417</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View File

@ -1,13 +1,9 @@
#include "qqttreeview.h"
#include "ui_qqttreeview.h"
#include <QFile>
#include <QHeaderView>
QQTTreeView::QQTTreeView(QWidget *parent) :
QTreeView(parent),
ui(new Ui::QQTTreeView)
QQtTreeView::QQtTreeView(QWidget* parent) :
QTreeView(parent)
{
ui->setupUi(this);
setSelectionMode(QAbstractItemView::SingleSelection);
setSelectionBehavior(QAbstractItemView::SelectRows);
setEditTriggers(QAbstractItemView::NoEditTriggers);
@ -25,18 +21,17 @@ QQTTreeView::QQTTreeView(QWidget *parent) :
#endif
}
QQTTreeView::~QQTTreeView()
QQtTreeView::~QQtTreeView()
{
delete ui;
}
void QQTTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const
void QQtTreeView::drawRow(QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index) const
{
return QTreeView::drawRow(painter, options, index);
}
void QQTTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const
void QQtTreeView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const
{
return QTreeView::drawBranches(painter, rect, index);
}

View File

@ -4,25 +4,20 @@
#include <QTreeView>
#include <qqt-local.h>
namespace Ui {
class QQTTreeView;
}
class QQTSHARED_EXPORT QQTTreeView : public QTreeView
class QQTSHARED_EXPORT QQtTreeView : public QTreeView
{
Q_OBJECT
public:
explicit QQTTreeView(QWidget *parent = 0);
~QQTTreeView();
explicit QQtTreeView(QWidget* parent = 0);
virtual ~QQtTreeView();
private:
Ui::QQTTreeView *ui;
// QQTTreeView interface
protected:
void drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const;
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const;
void drawRow(QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index) const;
void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const;
};
#endif // QQTTREEVIEW_H

View File

@ -1,21 +0,0 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>QQTTreeView</class>
<widget name="QQTTreeView" class="QTreeView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View File

@ -2,14 +2,11 @@
#include "ui_qqttreewidget.h"
#include "qqtxmltreemodel.h"
QQTTreeWidget::QQTTreeWidget(QWidget *parent) :
QQTTreeView(parent),
ui(new Ui::QQTTreeWidget)
QQtTreeWidget::QQtTreeWidget(QWidget* parent) :
QQtTreeView(parent)
{
ui->setupUi(this);
}
QQTTreeWidget::~QQTTreeWidget()
QQtTreeWidget::~QQtTreeWidget()
{
delete ui;
}

View File

@ -5,23 +5,18 @@
#include "qqttreemodel.h"
#include "qqt-local.h"
namespace Ui {
class QQTTreeWidget;
}
class QQTSHARED_EXPORT QQTTreeWidget : public QQTTreeView
class QQTSHARED_EXPORT QQtTreeWidget : public QQtTreeView
{
Q_OBJECT
public:
explicit QQTTreeWidget(QWidget *parent = 0);
~QQTTreeWidget();
explicit QQtTreeWidget(QWidget* parent = 0);
virtual ~QQtTreeWidget();
public slots:
private:
Ui::QQTTreeWidget *ui;
QQTTreeModel* mModel;
};

View File

@ -1,21 +0,0 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>QQTTreeWidget</class>
<widget name="QQTTreeWidget" class="QQTTreeView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View File

@ -1,19 +1,15 @@
#include "qqtwidget.h"
#include "ui_qqtwidget.h"
#include <QStylePainter>
#include "qqtcore.h"
QQtWidget::QQtWidget(QWidget* parent) :
QWidget(parent),
ui(new Ui::QQtWidget)
QWidget(parent)
{
ui->setupUi(this);
m_style = QQTCENTER;
}
QQtWidget::~QQtWidget()
{
delete ui;
}
void QQtWidget::setPixmap(QString pic)

View File

@ -1,21 +1,16 @@
#ifndef QPICWIDGET_H
#define QPICWIDGET_H
#ifndef QQTWIDGET_H
#define QQTWIDGET_H
#include <QWidget>
#include <qqt-local.h>
namespace Ui
{
class QQtWidget;
}
class QQTSHARED_EXPORT QQtWidget : public QWidget
{
Q_OBJECT
public:
explicit QQtWidget(QWidget* parent = 0);
~QQtWidget();
virtual ~QQtWidget();
enum ImageStyle
{
@ -35,7 +30,6 @@ signals:
void doubleClick();
private:
Ui::QQtWidget* ui;
QString m_pic;
quint32 m_style;
// QWidget interface

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QQtWidget</class>
<widget class="QWidget" name="QQtWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>27</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -20,16 +20,16 @@ extern "C" {
/*
*
*/
enum
typedef enum tagEBtnStatus
{
BTN_NORMAL = 0,
BTN_UNCHECK = BTN_NORMAL,
BTN_PRESS = 1,
BTN_CHECK = BTN_PRESS,
BTN_HOVER,
BTN_DISABLE,
BTN_HOVER = 2,
BTN_DISABLE = 3,
BTN_MAX,
};
} EBtnStatus;
#ifdef __cplusplus
}