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

add irregularwidgets and testcases about it.

This commit is contained in:
tianduanrui 2019-09-18 17:48:41 +08:00
parent c15e6ebc96
commit 3f6c7f9701
35 changed files with 1050 additions and 5 deletions

@ -1 +1 @@
Subproject commit dc29f516d964cca0ee92045c66e0801a5def35ac
Subproject commit 6d9651fd5ecc63ec1057411370b48ab87363d2ad

View File

@ -0,0 +1,8 @@
#include <qqtirregularlabel.h>
QQtIrregularLabel::QQtIrregularLabel ( QWidget* parent ) : QQtLabel ( parent )
{
setScaledContents ( true );
}
QQtIrregularLabel::~QQtIrregularLabel() {}

View File

@ -0,0 +1,20 @@
#ifndef QQTIRREGULARLABEL_H
#define QQTIRREGULARLABEL_H
#include <qqtlabel.h>
#include <qqt-local.h>
/**
* @brief The QQtIrregularLabel class
*
* setScaledContents
*/
class QQTSHARED_EXPORT QQtIrregularLabel : public QQtLabel
{
Q_OBJECT
public:
QQtIrregularLabel ( QWidget* parent = 0 );
virtual ~QQtIrregularLabel();
};
#endif //QQTIRREGULARLABEL_H

View File

@ -0,0 +1,22 @@
#include <qqtirregularpushbutton.h>
QQtIrregularPushbutton::QQtIrregularPushbutton ( QWidget* parent ) : QQtPushButton ( parent )
{
setAttribute ( Qt::WA_TranslucentBackground, true );
}
QQtIrregularPushbutton::~QQtIrregularPushbutton() {}
void QQtIrregularPushbutton::resizeEvent ( QResizeEvent* event )
{
QImage normalImage = QImage ( iconTable() [BTN_NORMAL] );
if ( normalImage.isNull() )
return QQtPushButton::resizeEvent ( event );
//zoom
setMask ( QPixmap::fromImage ( normalImage
.scaled ( rect().width(), rect().height(), Qt::IgnoreAspectRatio )
).mask() );
return QQtPushButton::resizeEvent ( event );
}

View File

@ -0,0 +1,25 @@
#ifndef QQTIRREGULARPUSHBUTTON_H
#define QQTIRREGULARPUSHBUTTON_H
#include <qqtpushbutton.h>
#include <qqt-local.h>
/**
* @brief The QQtIrregularPushbutton class
*
*
* 5姿NORMAL图片姿态一致
*/
class QQTSHARED_EXPORT QQtIrregularPushbutton : public QQtPushButton
{
Q_OBJECT
public:
QQtIrregularPushbutton ( QWidget* parent = 0 );
virtual ~QQtIrregularPushbutton();
// QWidget interface
protected:
virtual void resizeEvent ( QResizeEvent* event ) override;
};
#endif //QQTIRREGULARPUSHBUTTON_H

View File

@ -0,0 +1,196 @@
#include <qqtirregularwidget.h>
#include <QStylePainter>
QQtIrregularWidget::QQtIrregularWidget ( QWidget* parent ) : QQtWidget ( parent )
{
setAttribute ( Qt::WA_TranslucentBackground, true );
}
QQtIrregularWidget::~QQtIrregularWidget() {}
void QQtIrregularWidget::resizeEvent ( QResizeEvent* event )
{
if ( image().isNull() )
return QWidget::resizeEvent ( event );
switch ( imageStyle() )
{
case QQTCENTER:
{
#if 0
//无效
QWidget widget;
widget.resize ( size() );
QStylePainter painter ( &widget );
painter.drawItemPixmap ( widget.rect(), Qt::AlignCenter, QIcon ( QPixmap::fromImage ( image() ) ).pixmap ( widget.size(),
QIcon::Normal, QIcon::On ) );
setMask ( widget.mask() );
#endif
#if 1
//这个变量的跨平台特征,我很关心。
QImage resultImage ( size(), QImage::Format_ARGB32_Premultiplied );
resultImage.fill ( Qt::transparent );
QPainter painter ( &resultImage );
//pline() << painter.renderHints();
painter.setRenderHint ( QPainter::Antialiasing );
painter.setRenderHint ( QPainter::TextAntialiasing );
painter.setRenderHint ( QPainter::SmoothPixmapTransform );
//painter.setRenderHint ( QPainter::HighQualityAntialiasing );
//pline() << painter.renderHints();
//获取合理大小的pixmap 很可能会缩小一下
QPixmap pixmap;
#if 0
int w0, h0;
w0 = resultImage.width() - pixmap.width();
h0 = resultImage.height() - pixmap.height();
//这里的步骤其实就是QQtWidget里面CENTER效果QIcon干的事情。
//copy一点变化都没有
//scale就是裁切不知道为什么缩放全是裁切。
//为什么会有画面撕裂?
//QPixmap初始化后有进行赋值新的图片位置不一样然后撕裂了。所以pixmap只能赋值一次
//图片过大 缩小 无论如何都不行
if ( w0 < 0 || h0 < 0 )
pixmap = QPixmap::fromImage ( image()
.scaled ( resultImage.size(), Qt::KeepAspectRatio )
);
else if ( w0 < 0 && h0 < 0 )
pixmap = QPixmap::fromImage ( image()
.scaled ( resultImage.size(), Qt::KeepAspectRatio )
);
else if ( w0 < 0 )
pixmap = QPixmap::fromImage ( image()
.scaled ( resultImage.width(), image().height(), Qt::KeepAspectRatio )
);
else if ( h0 < 0 )
pixmap = QPixmap::fromImage ( image()
.scaled ( image().width(), resultImage.height(), Qt::KeepAspectRatio )
);
else
pixmap = QPixmap::fromImage ( image() );
#endif
#if 1
//偶尔会有重影所以resize的频率不要太高尤其在缩小的时候。
pixmap = QIcon ( QPixmap::fromImage ( image() ) ).pixmap ( resultImage.size(),
QIcon::Normal, QIcon::On );
#endif
//QQtWidget里面StylePainter自动居中绘制这里手动居中绘制。
//从合理位置开始绘制 很可能从中间开始绘制
int x0, y0;
x0 = ( resultImage.width() - pixmap.width() ) / 2;
y0 = ( resultImage.height() - pixmap.height() ) / 2;
x0 = x0 < 0 ? 0 : x0;
y0 = y0 < 0 ? 0 : y0;
painter.drawPixmap ( x0, y0, pixmap );
painter.end();
setMask ( QPixmap::fromImage ( resultImage ).mask() );
#if 0
static QQtWidget widget0;
widget0.resize ( size() );
widget0.setPixmap ( resultImage );
widget0.show();
static QQtWidget widget1;
widget1.resize ( pixmap.size() );
widget1.setPixmap ( pixmap );
widget1.show();
#endif
#endif
#if 0
//不居中
setMask ( QIcon ( QPixmap::fromImage ( image() ) ).pixmap ( rect().size(),
QIcon::Normal, QIcon::On ).mask() );
#endif
}
break;
case QQTTILEDWIDTH:
{
setMask ( QPixmap::fromImage ( image().copy ( rect() )
.scaledToWidth ( rect().width() )
).mask() );
}
break;
case QQTTILEDHEIGHT:
{
setMask ( QPixmap::fromImage ( image().copy ( rect() )
.scaledToHeight ( rect().height() )
).mask() );
}
break;
case QQTTILED:
{
setMask ( QPixmap::fromImage ( image().copy ( rect() )
.scaled ( rect().width(), rect().height(), Qt::KeepAspectRatio )
).mask() );
}
break;
case QQTZOOMWIDTH:
{
setMask ( QPixmap::fromImage ( image()
.scaled ( rect().width(), image().height(), Qt::IgnoreAspectRatio )
).mask() );
}
break;
case QQTZOOMHEIGHT:
{
setMask ( QPixmap::fromImage ( image()
.scaled ( image().width(), rect().height(), Qt::IgnoreAspectRatio )
).mask() );
}
break;
case QQTZOOM:
{
setMask ( QPixmap::fromImage ( image()
.scaled ( rect().width(), rect().height(), Qt::IgnoreAspectRatio )
).mask() );
}
break;
case QQTZOOMWIDTH_KEEPASPECTRATIO:
{
setMask ( QPixmap::fromImage ( image()
.scaled ( rect().width(), image().height(), Qt::KeepAspectRatio )
).mask() );
}
break;
case QQTZOOMHEIGHT_KEEPASPECTRATIO:
{
setMask ( QPixmap::fromImage ( image()
.scaled ( image().width(), rect().height(), Qt::KeepAspectRatio )
).mask() );
}
break;
case QQTZOOM_KEEPASPECTRATIO:
{
setMask ( QPixmap::fromImage ( image()
.scaled ( rect().width(), rect().height(), Qt::KeepAspectRatio )
).mask() );
}
break;
default:
{
}
break;
}
return QQtWidget::resizeEvent ( event );
}

View File

@ -0,0 +1,31 @@
#ifndef QQTIRREGULARWIDGET_H
#define QQTIRREGULARWIDGET_H
#include <qqtwidget.h>
#include <qqt-local.h>
/**
* @brief The QQtIrregularWidget class
*
* QQtOSDFrame
*
*
* alpha通道的图片即可
* mask设置为mask
*
* mask resizeEvent
* mask伴随图片的大小变化 resizeEvent
*/
class QQTSHARED_EXPORT QQtIrregularWidget : public QQtWidget
{
Q_OBJECT
public:
QQtIrregularWidget ( QWidget* parent = 0 );
virtual ~QQtIrregularWidget();
// QWidget interface
protected:
virtual void resizeEvent ( QResizeEvent* event ) override;
};
#endif //QQTIRREGULARWIDGET_H

View File

@ -166,7 +166,8 @@ void QQtApplication::setHighDpiScaling ( bool open )
{
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
setAttribute ( Qt::AA_EnableHighDpiScaling, open );
setAttribute ( Qt::AA_UseHighDpiPixmaps, open );
//这个设置好像没什么用如果打开了图片会被窗口吃掉一部分才开始缩小。如果不开就正常了。奇怪的图形坐标系。好像是个Qt BUG所以关闭。应该识别为放大了的可是没识别上边那个好像就把图片放大了。
//setAttribute ( Qt::AA_UseHighDpiPixmaps, open );
#endif
}

View File

@ -59,6 +59,7 @@ defineTest(add_include_QQt){
#exquisite widgets
command += $${header_path}/exquisite
command += $${header_path}/exquisite/irregularwidgets
command += $${header_path}/exquisite/clicksoundwidgets
command += $${header_path}/exquisite/clickwidgets
command += $${header_path}/exquisite/svgwidgets
@ -549,6 +550,9 @@ defineTest(add_defines_QQt){
#on screen display widget
DEFINES += __OSDWIDGETS__
#irregular widgets
DEFINES += __IRREGULARWIDGETS__
}
#---------------------------------------------------------------------------

View File

@ -341,12 +341,15 @@ contains (DEFINES, __NETWORKSUPPORT__) {
contains (DEFINES, __EXQUISITE__) {
#exquisite
#窗体移动
HEADERS += \
$$PWD/exquisite/qqtbodymover.h \
$$PWD/exquisite/qqtbodymover_p.h
SOURCES += \
$$PWD/exquisite/qqtbodymover.cpp \
$$PWD/exquisite/qqtbodymover_p.cpp
#窗体大小。一般用于无边框窗体
HEADERS += \
$$PWD/exquisite/qqtbodyresizer.h \
$$PWD/exquisite/qqtbodyresizer_p.h
@ -354,6 +357,24 @@ contains (DEFINES, __EXQUISITE__) {
$$PWD/exquisite/qqtbodyresizer.cpp \
$$PWD/exquisite/qqtbodyresizer_p.cpp
#不规则形状的控件
contains (DEFINES, __IRREGULARWIDGETS__) {
SOURCES += \
$$PWD/exquisite/irregularwidgets/qqtirregularwidget.cpp
HEADERS += \
$$PWD/exquisite/irregularwidgets/qqtirregularwidget.h
SOURCES += \
$$PWD/exquisite/irregularwidgets/qqtirregularlabel.cpp
HEADERS += \
$$PWD/exquisite/irregularwidgets/qqtirregularlabel.h
SOURCES += \
$$PWD/exquisite/irregularwidgets/qqtirregularpushbutton.cpp
HEADERS += \
$$PWD/exquisite/irregularwidgets/qqtirregularpushbutton.h
}
#can click sound support widgets
contains (DEFINES, __CLICKSOUNDWIDGETS__) {
SOURCES += \

View File

@ -12,6 +12,8 @@ QQtWidget::~QQtWidget()
{
}
QQtWidget::ImageStyle QQtWidget::imageStyle() { return m_style; }
void QQtWidget::setImageStyle ( QQtWidget::ImageStyle style ) { m_style = style; }
void QQtWidget::setPixmap ( const QString& pic )
@ -28,6 +30,13 @@ void QQtWidget::setPixmap ( const QPixmap& pixmap )
update();
}
QImage QQtWidget::image() { return mImage; }
void QQtWidget::setImage ( const QImage& image )
{
setPixmap ( image );
}
void QQtWidget::setPixmap ( const QImage& image )
{
mImage = image;

View File

@ -55,17 +55,22 @@ public:
explicit QQtWidget ( QWidget* parent = 0 );
virtual ~QQtWidget();
ImageStyle imageStyle();
void setImageStyle ( ImageStyle style = QQTCENTER );
void setPixmap ( const QString& pic = QString() );
void setPixmap ( const QPixmap& pixmap );
void setPixmap ( const QImage& image );
void setPixmap ( const QString& pic );
void setPixmap ( const QPixmap& pixmap );
QImage image();
void setImage ( const QImage& image );
// QWidget interface
protected:
void paintEvent ( QPaintEvent* ) override;
private:
quint32 m_style;
ImageStyle m_style;
/*pixmap是必要的。绘图用pixmap。*/
/*内部没有使用QPixmap存储因为如果缩放widgetpixmap就没办法了img有*/
/*内部对QIcon的使用删除了icon不是必要的。*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,24 @@
/*spinbox 抬起样式*/
QTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button {
subcontrol-origin:border;
subcontrol-position:right;
width: 12px;
}
QTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button {
subcontrol-origin:border;
subcontrol-position:left;
width: 12px;
}
/*按钮按下样式*/
QTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{
subcontrol-origin:border;
subcontrol-position:right;
width: 12px;
}
QTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{
subcontrol-position:left;
width: 12px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.example.testirregularwidgets" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="testirregularwidgets" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="testirregularwidgets" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="testirregularwidgets"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so"/>
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroid-bundled.jar"/>
<meta-data android:name="android.app.static_init_classes" android:value=""/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

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

View File

@ -0,0 +1,106 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qqtirregularwidget.h>
#include <qqtclickhelper.h>
#include <qqtframe.h>
#include <qqtbodymover.h>
#include <qqtbodyresizer.h>
#include <qqtirregularpushbutton.h>
MainWindow::MainWindow ( QWidget* parent ) :
QMainWindow ( parent ),
ui ( new Ui::MainWindow )
{
ui->setupUi ( this );
//用户设置图片就可以了,图像就已经裁切好了,已经变形了,透明部分已经不能点击了。
//而且当图片跟随窗口大小改变mask的部分也跟随变化跟QQtWidget的imageStyle有关系。
ui->widget->setPixmap ( conf_root ( "a1.png" ) );
QQtClickHelper* clicker = new QQtClickHelper ( this );
connect ( clicker, SIGNAL ( clickWithPoint ( QPoint ) ), this, SLOT ( clicked1 ( QPoint ) ) );
ui->widget->installEventFilter ( clicker );
//加个信号
QQtBodyMover* mover = new QQtBodyMover ( this );
//ui->widget_8->installEventFilter ( mover );
//加个信号
QQtBodyResizer* resizer = new QQtBodyResizer ( this );
//ui->widget_8->installEventFilter ( resizer );
//center normal
ui->widget_12->setPixmap ( conf_root ( "a1.png" ) );
//zoom
ui->widget_2->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_2->setImageStyle ( QQtWidget::QQTZOOM );
ui->widget_2->installEventFilter ( clicker );
//zoom keep aspect ratio
ui->widget_21->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_21->setImageStyle ( QQtWidget::QQTZOOM_KEEPASPECTRATIO );
ui->widget_21->installEventFilter ( clicker );
//tiled
ui->widget_7->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_7->setImageStyle ( QQtWidget::QQTTILED );
ui->widget_7->installEventFilter ( clicker );
//other
ui->widget_15->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_15->setImageStyle ( QQtWidget::QQTZOOMWIDTH );
ui->widget_15->installEventFilter ( clicker );
ui->widget_16->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_16->setImageStyle ( QQtWidget::QQTZOOMHEIGHT );
ui->widget_16->installEventFilter ( clicker );
ui->widget_17->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_17->setImageStyle ( QQtWidget::QQTZOOMWIDTH_KEEPASPECTRATIO );
ui->widget_17->installEventFilter ( clicker );
ui->widget_18->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_18->setImageStyle ( QQtWidget::QQTZOOMHEIGHT_KEEPASPECTRATIO );
ui->widget_18->installEventFilter ( clicker );
ui->widget_19->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_19->setImageStyle ( QQtWidget::QQTTILEDWIDTH );
ui->widget_19->installEventFilter ( clicker );
ui->widget_20->setPixmap ( conf_root ( "a1.png" ) );
ui->widget_20->setImageStyle ( QQtWidget::QQTTILEDHEIGHT );
ui->widget_20->installEventFilter ( clicker );
ui->pushButton->iconTable().initNormal ( conf_root ( "close_0.png" ), conf_root ( "close_01.png" ) );
ui->pushButton->iconTable().initCheck ( conf_root ( "close_0.png" ), conf_root ( "close_01.png" ) );
ui->pushButton->iconTable().initOther ( conf_root ( "close_01.png" ), conf_root ( "close_01.png" ) );
connect ( ui->pushButton, SIGNAL ( clicked ( bool ) ), this, SLOT ( clicked2() ) );
ui->widget_22->setPixmap ( conf_root ( "second_0.png" ) );
ui->widget_22->setImageStyle ( QQtWidget::QQTZOOM );
ui->widget_22->installEventFilter ( clicker );
ui->widget_23->setPixmap ( conf_root ( "third_0.png" ) );
ui->widget_23->setImageStyle ( QQtWidget::QQTZOOM );
ui->widget_23->installEventFilter ( clicker );
ui->widget_24->setPixmap ( conf_root ( "four_0.png" ) );
ui->widget_24->setImageStyle ( QQtWidget::QQTZOOM );
ui->widget_24->installEventFilter ( clicker );
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::clicked1 ( QPoint point )
{
pline() << point;
}
void MainWindow::clicked2()
{
pline();
}

View File

@ -0,0 +1,25 @@
#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();
public slots:
void clicked1 ( QPoint point );
void clicked2();
private:
Ui::MainWindow* ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,380 @@
<?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>547</width>
<height>415</height>
</rect>
</property>
<property name="windowTitle">
<string>testirregularwidgets</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>center</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QWidget" name="widget_9" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QWidget" name="widget_10" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget_11" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QQtWidget" name="widget_12" native="true"/>
</item>
<item row="1" column="2">
<widget class="QWidget" name="widget_13" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="widget_14" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string> center mask</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QWidget" name="widget_8" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QWidget" name="widget_5" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget_3" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QQtIrregularWidget" name="widget" native="true"/>
</item>
<item row="1" column="2">
<widget class="QWidget" name="widget_6" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="widget_4" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>zoom mask</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QQtIrregularWidget" name="widget_2" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>zoom keepaspectratio</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QQtIrregularWidget" name="widget_21" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>tiled mask</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QQtIrregularWidget" name="widget_7" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Other mask</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QQtIrregularWidget" name="widget_15" native="true"/>
</item>
<item row="0" column="1">
<widget class="QQtIrregularWidget" name="widget_16" native="true"/>
</item>
<item row="1" column="0">
<widget class="QQtIrregularWidget" name="widget_17" native="true"/>
</item>
<item row="1" column="1">
<widget class="QQtIrregularWidget" name="widget_18" native="true"/>
</item>
<item row="2" column="0">
<widget class="QQtIrregularWidget" name="widget_19" native="true"/>
</item>
<item row="2" column="1">
<widget class="QQtIrregularWidget" name="widget_20" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_7">
<attribute name="title">
<string>button mask</string>
</attribute>
<widget class="QQtIrregularPushbutton" name="pushButton">
<property name="geometry">
<rect>
<x>280</x>
<y>50</y>
<width>101</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QQtIrregularWidget" name="widget_22" native="true">
<property name="geometry">
<rect>
<x>200</x>
<y>50</y>
<width>111</width>
<height>71</height>
</rect>
</property>
</widget>
<widget class="QQtIrregularWidget" name="widget_23" native="true">
<property name="geometry">
<rect>
<x>130</x>
<y>50</y>
<width>101</width>
<height>71</height>
</rect>
</property>
</widget>
<widget class="QQtIrregularWidget" name="widget_24" native="true">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>91</width>
<height>71</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<height>17</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QQtIrregularWidget</class>
<extends>QWidget</extends>
<header>qqtirregularwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QQtWidget</class>
<extends>QWidget</extends>
<header>qqtwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QQtIrregularPushbutton</class>
<extends>QPushButton</extends>
<header>qqtirregularpushbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,66 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-10-06T08:16:10
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = testirregularwidgets
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
include($${PWD}/../../multi-link/add_base_manager.pri)
#-------------------------------------------------
#用户工程配置
#-------------------------------------------------
add_version(1,0,0,0)
add_deploy()
add_deploy_config($${PWD}/AppRoot)
add_dependent_manager(QQt)
system(touch main.cpp)
#-------------------------------------------------
#用户工程配置
#-------------------------------------------------
equals(QSYS_PRIVATE, macOS) {
CONFIG += app_bundle
}
contains(QSYS_PRIVATE, Android|AndroidX86) {
CONFIG += mobility
MOBILITY =
DISTFILES += \
android/AndroidManifest.xml
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
}
message ($${TARGET} config $${CONFIG})
message ($${TARGET} DEFINE $${DEFINES})
message ($${TARGET} prelink $${QMAKE_PRE_LINK})
message ($${TARGET} postlink $${QMAKE_POST_LINK})