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

修复嵌入式linux目标上,opengl的相关代码,移走QGLWidget的引用

This commit is contained in:
tianduanrui 2019-09-25 10:48:29 +08:00
parent 2e52825fd0
commit 2b620af1b5
8 changed files with 73 additions and 61 deletions

View File

@ -1,8 +1,9 @@
#include "qqtopenglwidget.h"
QQtOpenGLWidget::QQtOpenGLWidget ( QWidget* parent ) : QGLWidget ( parent )
QQtOpenGLWidget::QQtOpenGLWidget ( QWidget* parent ) : QOpenGLWidget ( parent )
{
pmGLFunctions = new QGLFunctions ( this->context() );
pmGLFunctions = new QOpenGLFunctions ( this->context() );
pmGLFunctions->initializeOpenGLFunctions();
pline() << "Qt OpenGL Function GL feature:" << hex << pmGLFunctions->openGLFeatures();
}
@ -19,6 +20,8 @@ void QQtOpenGLWidget::initializeGL()
//设置清除时颜色
glClearColor ( 0.0, 0.0, 0.0, 0 );
#endif
initializeOverlayGL();
}
void QQtOpenGLWidget::resizeGL ( int w, int h )
@ -35,6 +38,8 @@ void QQtOpenGLWidget::resizeGL ( int w, int h )
glLoadIdentity();
gluLookAt ( 0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );
#endif
resizeOverlayGL ( w, h );
}
void QQtOpenGLWidget::paintGL()
@ -48,6 +53,7 @@ void QQtOpenGLWidget::paintGL()
#endif
glFuncs()->glClearDepthf ( 0 );
paintOverlayGL();
}
void QQtOpenGLWidget::initializeOverlayGL()
@ -61,16 +67,3 @@ void QQtOpenGLWidget::resizeOverlayGL ( int w, int h )
void QQtOpenGLWidget::paintOverlayGL()
{
}
void QQtOpenGLWidget::mousePressEvent ( QMouseEvent* event )
{
}
void QQtOpenGLWidget::mouseReleaseEvent ( QMouseEvent* event )
{
}
void QQtOpenGLWidget::mouseDoubleClickEvent ( QMouseEvent* event )
{
}

View File

@ -1,8 +1,14 @@
#ifndef QQTOPENGLWIDGET_H
#define QQTOPENGLWIDGET_H
#include <QGLWidget>
#include <QGLFunctions>
/**
* QOpenGL与QGL不同
* QOpenGLWidget属于Widgets库QOpenGLFunctions属于GUI库;
* QGLWidget属于opengl库QGLFunctions属于opengl库
* ARMHF32AndroidQt对opengl库支持的并不好
*/
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include "qqtcore.h"
#include "qqt-local.h"
@ -12,20 +18,14 @@
#include <GL/glu.h>
#endif
/**
*
* QOpenGLWidget need? QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
* OpenGL ES库OpenGL ES库中是不支持glBegin()OpenGL库
*/
/**
* @brief The QQtOpenGLWidget class
* 便QGLWidget
* 便QOpenGLWidget
*
* Windows平台
* Android平台
*/
class QQTSHARED_EXPORT QQtOpenGLWidget : public QGLWidget
class QQTSHARED_EXPORT QQtOpenGLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
@ -33,12 +33,7 @@ public:
~QQtOpenGLWidget();
//获取GL操作函数
QGLFunctions* glFuncs() const { return pmGLFunctions; }
//用户自定义GLWidget Context。
void useCustomContext ( QGLContext* context ) {
setContext ( context );
glFuncs()->initializeGLFunctions ( context );
}
QOpenGLFunctions* glFuncs() const { return pmGLFunctions; }
signals:
@ -47,27 +42,20 @@ public slots:
protected:
// 用户继承下去,实现显示。
// QGLWidget interface
// QOpenGLWidget interface
protected:
//背景
virtual void initializeGL() override;
virtual void resizeGL ( int w, int h ) override;
virtual void paintGL() override;
//漂浮物
virtual void initializeOverlayGL() override;
virtual void resizeOverlayGL ( int w, int h ) override;
virtual void paintOverlayGL() override;
virtual void initializeOverlayGL();
virtual void resizeOverlayGL ( int w, int h );
virtual void paintOverlayGL();
protected:
private:
QGLFunctions* pmGLFunctions;
// 按钮信号 左键 右键 长按 带点
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) override;
virtual void mouseReleaseEvent ( QMouseEvent* event ) override;
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) override;
QOpenGLFunctions* pmGLFunctions;
};
#endif // QQTOPENGLWIDGET_H

View File

@ -1,7 +1,7 @@
#ifndef QQTOPENGLWINDOW_H
#define QQTOPENGLWINDOW_H
#include <QGLWidget>
#include <QOpenGLWidget>
#include "qqtcore.h"
#include "qqt-local.h"
@ -10,16 +10,16 @@
* @brief The QQtOpenGLWindow class
* Apple平台和Windows平台对OpenGL API使用加以了限制使bug的限制
* Qt建议使用一个OpenGL Widget Parent窗口来解决这些限制可能引起的bug
* LibQQt要求Qt OpenGL Widget都必须在这个OpenGL parent下成为子孙GLWidget和漂浮GLWidgetQt OpenGL Widget唯一的Root父亲
* LibQQt要求Qt OpenGL Widget都必须在这个OpenGL parent下成为子孙OpenGLWidget和漂浮OpenGLWidgetQt OpenGL Widget唯一的Root父亲
* main函数里OpenGL窗口的唯一入口
* 便GL窗口OpenGL Widget的parent存在
* 便OpenGL窗口OpenGL Widget的parent存在
* MainWindow下添加centralWidget
*/
class QQTSHARED_EXPORT QQtOpenGLWindow : public QGLWidget
class QQTSHARED_EXPORT QQtOpenGLWindow : public QOpenGLWidget
{
Q_OBJECT
public:
explicit QQtOpenGLWindow ( QWidget* parent = nullptr ) : QGLWidget ( parent ) {
explicit QQtOpenGLWindow ( QWidget* parent = nullptr ) : QOpenGLWidget ( parent ) {
}
~QQtOpenGLWindow() {

View File

@ -15,8 +15,10 @@ QQtWebAccessManager::QQtWebAccessManager ( QObject* parent ) : QNetworkAccessMan
connect ( this, SIGNAL ( proxyAuthenticationRequired ( QNetworkProxy, QAuthenticator* ) ),
this, SLOT ( proxyAuthenticationRequired ( QNetworkProxy, QAuthenticator* ) ) );
#ifdef __SSLSUPPORT__
connect ( this, SIGNAL ( sslErrors ( QNetworkReply*, QList<QSslError> ) ),
this, SLOT ( sslErrors ( QNetworkReply*, QList<QSslError> ) ) );
#endif
connect ( this, SIGNAL ( networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility ) ),
this, SLOT ( networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility ) ) );
@ -66,6 +68,7 @@ QQtWebAccessSession* QQtWebAccessManager::sendGetRequest ( QString strUrl )
netRequest.setHeader ( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );
netRequest.setUrl ( QUrl ( strUrl ) ); //地址信息
#ifdef __SSLSUPPORT__
if ( strUrl.toLower().startsWith ( "https" ) ) //https请求需ssl支持(下载openssl拷贝libeay32.dll和ssleay32.dll文件至Qt bin目录或程序运行目录)
{
QSslConfiguration sslConfig;
@ -73,6 +76,7 @@ QQtWebAccessSession* QQtWebAccessManager::sendGetRequest ( QString strUrl )
sslConfig.setProtocol ( QSsl::TlsV1_1 );
netRequest.setSslConfiguration ( sslConfig );
}
#endif
QQtWebAccessSession* session = sendGetRequest ( netRequest );
@ -385,7 +389,7 @@ QQtWebAccessSession* QQtWebAccessManager::sendDeleteResourceRequest ( const QNet
}
QQtWebAccessSession* QQtWebAccessManager::sendCustomRequest ( const QNetworkRequest& request, const QByteArray& verb,
QIODevice* data )
QIODevice* data )
{
QQtWebAccessSession* session = manager->newWebAccessSession();
session->webAccessRequest() = request;
@ -422,7 +426,7 @@ QQtWebAccessSession* QQtWebAccessManager::sendCustomRequest ( const QNetworkRequ
#if QT_VERSION > QT_VERSION_CHECK(5,7,1)
QQtWebAccessSession* QQtWebAccessManager::sendCustomRequest ( const QNetworkRequest& request, const QByteArray& verb,
const QByteArray& data )
const QByteArray& data )
{
QQtWebAccessSession* session = manager->newWebAccessSession();
session->webAccessRequest() = request;
@ -456,7 +460,7 @@ QQtWebAccessSession* QQtWebAccessManager::sendCustomRequest ( const QNetworkRequ
}
QQtWebAccessSession* QQtWebAccessManager::sendCustomRequest ( const QNetworkRequest& request, const QByteArray& verb,
QHttpMultiPart* multiPart )
QHttpMultiPart* multiPart )
{
QQtWebAccessSession* session = manager->newWebAccessSession();
session->webAccessRequest() = request;
@ -518,10 +522,12 @@ void QQtWebAccessManager::proxyAuthenticationRequired ( QNetworkProxy p, QAuthen
//pline() << p.hostName() << a;
}
#ifdef __SSLSUPPORT__
void QQtWebAccessManager::sslErrors ( QNetworkReply* r, QList<QSslError> e )
{
//pline() << r << e.size();
}
#endif
void QQtWebAccessManager::networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility a )
{

View File

@ -7,7 +7,9 @@
//import this struct will not build fail
#include <QNetworkProxy>
#ifdef __SSLSUPPORT__
#include <QSslError>
#endif
#include <QStringList>
#include <QUuid>
@ -239,7 +241,7 @@ public:
QQtWebAccessSession* sendPutRequest ( const QNetworkRequest& request, QHttpMultiPart* multiPart );
QQtWebAccessSession* sendDeleteResourceRequest ( const QNetworkRequest& request );
QQtWebAccessSession* sendCustomRequest ( const QNetworkRequest& request, const QByteArray& verb,
QIODevice* data = Q_NULLPTR );
QIODevice* data = Q_NULLPTR );
//win没有这几个函数
//arm下5.5.1没有
@ -249,9 +251,9 @@ public:
#if defined( __DARWIN__ ) || defined( __LINUX__ )
#if QT_VERSION > QT_VERSION_CHECK(5,7,1)
QQtWebAccessSession* sendCustomRequest ( const QNetworkRequest& request, const QByteArray& verb,
const QByteArray& data );
const QByteArray& data );
QQtWebAccessSession* sendCustomRequest ( const QNetworkRequest& request, const QByteArray& verb,
QHttpMultiPart* multiPart );
QHttpMultiPart* multiPart );
#endif
#endif
@ -270,7 +272,9 @@ private slots:
void finished ( QNetworkReply* reply );
void authenticationRequired ( QNetworkReply*, QAuthenticator* );
void proxyAuthenticationRequired ( QNetworkProxy, QAuthenticator* );
#ifdef __SSLSUPPORT__
void sslErrors ( QNetworkReply*, QList<QSslError> );
#endif
void networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility );
void networkSessionConnected();

View File

@ -446,7 +446,7 @@ defineTest(add_defines_QQt){
#if you use QNetworkAccessManagerSupport , open this annotation
DEFINES += __WEBACCESSSUPPORT__
lessThan(QT_MAJOR_VERSION, 5): DEFINES -= __WEBACCESSSUPPORT__
contains(QSYS_PRIVATE, Arm32|Armhf32 || Mips32 || Embedded):DEFINES -= __WEBACCESSSUPPORT__
contains(DEFINES, __EMBEDDED_LINUX__):DEFINES -= __WEBACCESSSUPPORT__
contains (DEFINES, __WEBACCESSSUPPORT__) {
#QSslError not found, you need recompiler Qt4
}
@ -460,16 +460,21 @@ defineTest(add_defines_QQt){
contains (DEFINES, __WEBENGINESUPPORT__) {
}
#Qt4 QSslError not found, you need recompiler Qt4
DEFINES += __SSLSUPPORT__
#ARMHF32 MIPS32 不支持
contains(DEFINES, __EMBEDDED_LINUX__):DEFINES -= __SSLSUPPORT__
contains (DEFINES, __SSLSUPPORT__) {
}
##################WebSocket Module###############################
#Multi New Protocol 全双工 QWebSocket
#if you use QWebSocketSupport , open this annotation
DEFINES += __WEBSOCKETSUPPORT__
#equals(QSYS_PRIVATE, macOS):DEFINES += __WEBSOCKETSUPPORT__
lessThan(QT_MAJOR_VERSION, 5): DEFINES -= __WEBSOCKETSUPPORT__
contains (DEFINES, __WEBSOCKETSUPPORT__) {
QT += websockets
#Qt4 QSslError not found, you need recompiler Qt4
#TODO: QT += webkit
#QSslError not found, you need recompiler Qt4
}
#c++ html parser query
@ -557,10 +562,22 @@ defineTest(add_defines_QQt){
}
}
#opengl module
#opengl module [widgets,gui]
DEFINES += __OPENGLWIDGETS__
contains(QSYS_PRIVATE, Arm32|Armhf32 || Mips32 || Embedded):DEFINES-=__OPENGLWIDGETS__
#ARMHF32, MIPS32 不支持
contains(DEFINES, __EMBEDDED_LINUX__):DEFINES -= __OPENGLWIDGETS__
contains (DEFINES, __OPENGLWIDGETS__) {
}
#gl module [opengl]
#Windows, macOS, Linux
#WinRT, Android, iOS
#ARMHF32, MIPS32 不支持
DEFINES += __GLWIDGETS__
contains(DEFINES, __EMBEDDED_LINUX__):DEFINES -= __GLWIDGETS__
#内部没有提供任何关于opengl库的代码。
DEFINES -= __GLWIDGETS__
contains (DEFINES, __GLWIDGETS__) {
QT += opengl
}

View File

@ -86,7 +86,7 @@ bool MainWindow::eventFilter ( QObject* watched, QEvent* event )
QPoint mousePos = QCursor::pos();
qreal ratio = 1; w.devicePixelRatioF();
qreal ratio = 1; //w.devicePixelRatioF();
QRect r0 = QRect ( p0, p1 );
QRect qr0 = QRect ( QPoint ( r0.left() * ratio, r0.top() * ratio ),
QPoint ( r0.right() * ratio, r0.bottom() * ratio ) );

View File

@ -107,6 +107,9 @@ win32:!cross_compile {
#-------------------------------------------------
#用户工程配置
#-------------------------------------------------
#嵌入式上不支持这个东西
QT-=opengl
equals(QSYS_PRIVATE, macOS) {
CONFIG += app_bundle
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
@ -122,6 +125,7 @@ contains(QSYS_PRIVATE, Android|AndroidX86) {
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
}
message ($${TARGET} Qt $${QT})
message ($${TARGET} config $${CONFIG})
message ($${TARGET} DEFINE $${DEFINES})
message ($${TARGET} prelink $${QMAKE_PRE_LINK})