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

add testcase, testwindowattribute and widgeteffect.

This commit is contained in:
tianduanrui 2019-08-26 10:34:26 +08:00
parent d9cd63d091
commit a6fdada17c
21 changed files with 600 additions and 1 deletions

View File

@ -4,7 +4,8 @@
int main ( int argc, char* argv[] )
{
//QQtApplication::setHighDpiScaling();
QQtApplication::setHighDpiScaling();
QQtApplication a ( argc, argv );
//MainWindow w;

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;
}

View File

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.example.testwindowattribute" 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="testwindowattribute" 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="testwindowattribute" 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="testwindowattribute"/>
<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,54 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qqtwindowattribute.h>
#include <qqtwidgeteffect.h>
#include <QGraphicsEffect>
MainWindow::MainWindow ( QWidget* parent ) :
QMainWindow ( parent ),
ui ( new Ui::MainWindow )
{
ui->setupUi ( this );
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
setFullScreen ( this, true );
}
void MainWindow::on_pushButton_2_clicked()
{
setFullScreen ( this, false );
}
void MainWindow::on_pushButton_3_clicked()
{
setShadowEffect ( this );
}
void MainWindow::on_pushButton_4_clicked()
{
graphicsEffect()->setEnabled ( false );
}
void MainWindow::on_pushButton_5_clicked()
{
setMainWindow ( this, true );
}
void MainWindow::on_pushButton_6_clicked()
{
setMainWindow ( this, false );
}
void MainWindow::on_pushButton_7_clicked()
{
setFadeEffect ( this );
}

View File

@ -0,0 +1,37 @@
#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 slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_pushButton_5_clicked();
void on_pushButton_6_clicked();
void on_pushButton_7_clicked();
private:
Ui::MainWindow* ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,168 @@
<?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>540</width>
<height>353</height>
</rect>
</property>
<property name="windowTitle">
<string>testwindowattribute</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FullScreen</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>NormalScreen</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>240</x>
<y>30</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>ShadowEffect</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>240</x>
<y>80</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Close ShadowEffect</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_5">
<property name="geometry">
<rect>
<x>30</x>
<y>150</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Main Window</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_6">
<property name="geometry">
<rect>
<x>30</x>
<y>190</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Sub Window</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_7">
<property name="geometry">
<rect>
<x>240</x>
<y>150</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>FadeEffect</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>540</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"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,34 @@
#include <qqtwidgeteffect.h>
#include <QGraphicsEffect>
#include <qqtanimation.h>
void setShadowEffect ( QWidget* widget )
{
Q_ASSERT ( widget );
/*
* blurRadius
* dx x方向阴影位置和偏移量
* dy y方向阴影位置和偏移量
*/
static QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect;
shadow->setBlurRadius ( 10 );
shadow->setColor ( QColor ( 0, 0, 0, 160 ) );
shadow->setOffset ( 5, 5 );
shadow->setEnabled ( true );
widget->setGraphicsEffect ( shadow );
}
void setFadeEffect ( QWidget* widget, quint32 millseconds, qreal startOpacity, qreal endOpacity )
{
Q_ASSERT ( widget );
static QPropertyAnimation* show_animation_ = new QPropertyAnimation ( widget, "windowOpacity" );
show_animation_->setDuration ( millseconds );
show_animation_->setStartValue ( startOpacity );
show_animation_->setEndValue ( endOpacity );
show_animation_->start();
widget->show();
}

View File

@ -0,0 +1,15 @@
#ifndef QQTWIDGETEFFECT_H
#define QQTWIDGETEFFECT_H
#include <QWidget>
//#include <qqt-local.h>
#define QQTSHARED_EXPORT
//shadow effect (子控件)
void QQTSHARED_EXPORT setShadowEffect ( QWidget* widget );
//fade effect
void QQTSHARED_EXPORT setFadeEffect ( QWidget* widget, quint32 millseconds = 2000, qreal startOpacity = 0, qreal endOpacity = 1 );
#endif // QQTWIDGETEFFECT_H

View File

@ -0,0 +1,59 @@
#include <qqtwindowattribute.h>
#include <QWidget>
#include <qqtcore.h>
#include <qqtwidgets.h>
void setFrameless ( QWidget* widget, bool open )
{
Q_ASSERT ( widget );
pline() << widget->windowFlags();
if ( open )
widget->setWindowFlags ( Qt::FramelessWindowHint | widget->windowFlags() );
else
widget->setWindowFlag ( Qt::FramelessWindowHint, false );
pline() << widget->windowFlags();
}
void setMainWindow ( QWidget* widget, bool open )
{
Q_ASSERT ( widget );
pline() << widget->windowFlags();
if ( open )
{
widget->setWindowFlags ( Qt::Window | widget->windowFlags() );
widget->setWindowFlag ( Qt::SubWindow, false );
}
else
{
//独立的子窗口是不存在的。
widget->setWindowFlag ( Qt::Widget, true );
//怎么了,不能单独使用。
//widget->setWindowFlags ( Qt::SubWindow | widget->windowFlags() );
}
pline() << widget->windowFlags();
}
void setFullScreen ( QWidget* widget, bool open, QRect normalGeometry )
{
Q_ASSERT ( widget );
pline() << widget->windowFlags();
if ( open )
{
//确保不是子窗口
widget->setWindowFlags ( Qt::Window | widget->windowFlags() );
widget->setWindowFlags ( Qt::FramelessWindowHint | widget->windowFlags() );
widget->showFullScreen();
}
else
{
//确保不是子窗口
widget->setWindowFlags ( Qt::Window | widget->windowFlags() );
//取消frameless
widget->setWindowFlag ( Qt::FramelessWindowHint, false );
widget->showNormal();
widget->setGeometry ( normalGeometry );
moveCenter ( widget );
}
pline() << widget->windowFlags();
}

View File

@ -0,0 +1,22 @@
#ifndef QQTWINDOWATTRIBUTE_H
#define QQTWINDOWATTRIBUTE_H
#include <QWidget>
//#include <qqt-local.h>
#define QQTSHARED_EXPORT
//frameless
void QQTSHARED_EXPORT setFrameless ( QWidget* widget, bool open = true );
//主、子窗口
void QQTSHARED_EXPORT setMainWindow ( QWidget* widget, bool open = true );
//full screen (normal screen, +size)
void QQTSHARED_EXPORT setFullScreen ( QWidget* widget, bool open = true, QRect normalGeometry = QRect ( 0, 0, 800, 600 ) );
//子窗体填充主窗体
#endif // QQTWINDOWATTRIBUTE_H

View File

@ -0,0 +1,83 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-10-06T08:16:10
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = testwindowattribute
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)
CONFIG += use_source
use_source {
add_file(qqtwindowattribute.h)
add_file(qqtwindowattribute.cpp)
add_file(qqtwidgeteffect.h)
add_file(qqtwidgeteffect.cpp)
HEADERS += \
qqtwindowattribute.h \
qqtwidgeteffect.h
SOURCES += \
qqtwindowattribute.cpp \
qqtwidgeteffect.cpp
}
#-------------------------------------------------
#用户工程配置
#-------------------------------------------------
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})