经过测试qml不能用,只能小窗口widget

This commit is contained in:
2020-04-20 19:56:15 +08:00
parent 00ede2b496
commit 25d8e37764
7 changed files with 82 additions and 28 deletions
+1 -1
View File
@@ -184,7 +184,7 @@ void MainWindow::resizeEvent(QResizeEvent *event)
this->height());
nav1->setGeometry(nav->width(),0,nav->width(),this->height());
//nav1->setGeometry(nav->width(),0,nav->width(),this->height());
nav->setGeometry(0,0,nav->width(),this->height());
copk->setGeometry(this->width() - copk->width(),0,copk->width(),copk->height());
+1
View File
@@ -33,4 +33,5 @@
<file>MavCmdInfoSub.json</file>
<file>MavCmdInfoVTOL.json</file>
</qresource>
<qresource prefix="/qml"/>
</RCC>
+9 -6
View File
@@ -4,10 +4,11 @@ QT += opengl
QT += network
QT += sql
QT += svg
#QT += quickwidgets
#QT += quick
#QT += qml
QT += quickwidgets
QT += quick
QT += qml
#CONFIG+=qtquickcompiler
TEMPLATE = lib
@@ -42,7 +43,7 @@ SOURCES += $$PWD/mapgraphicitem.cpp \
$$PWD/traillineitem.cpp \
$$PWD/waypointline.cpp \
$$PWD/waypointcircle.cpp \
propertyui.cpp
$$PWD/propertyui.cpp
@@ -63,8 +64,8 @@ HEADERS += $$PWD/mapgraphicitem.h \
$$PWD/traillineitem.h \
$$PWD/waypointline.h \
$$PWD/waypointcircle.h \
mapwidgetglobal.h \
propertyui.h
$$PWD/mapwidgetglobal.h \
$$PWD/propertyui.h
RESOURCES += mapresources.qrc
@@ -115,3 +116,5 @@ win32|win64 {
+15 -7
View File
@@ -45,22 +45,28 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
config->SetCacheLocation("./maps/");
//p_ui = new propertyui();
p_ui = new propertyui();
//p_ui->setGeometry(this->width() - 100,0,100,this->height());
//p_ui->setWindowTitle(tr("Way Point Setting"));
//p_ui->show();
p_ui->setWindowTitle(tr("Way Point Setting"));
p_ui->setWindowFlags(p_ui->windowFlags() | Qt::WindowStaysOnTopHint);
p_ui->show();
map = new MapGraphicItem(core, config);
//map->setOpacity(0.1);
//添加了这个之后就出 问题
//mscene.addWidget(p_ui);
mscene.addItem(map);//添加图层
this->setScene(&mscene);
Home = new HomeItem(map, this);
Home->setParentItem(map);
@@ -184,17 +190,19 @@ void OPMapWidget::SetShowHome(const bool &value)
void OPMapWidget::resizeEvent(QResizeEvent *event)
{
if (scene()) {
scene()->setSceneRect(
QRect(QPoint(0, 0), event->size()));
QRect(QPoint(0,0), event->size()));
}
QGraphicsView::resizeEvent(event);
if (compass) {
compass->setScale(0.1 + 0.05 * (qreal)(event->size().width()) / 1000 * (qreal)(event->size().height()) / 600);
}
qDebug() << this->size();
//p_ui->setGeometry(300,0,100,500);
//p_ui->setGeometry(this->width() - 100,0,100,this->height());
}
QSize OPMapWidget::sizeHint() const
@@ -209,12 +217,12 @@ void OPMapWidget::showEvent(QShowEvent *event)
}
OPMapWidget::~OPMapWidget()
{
/*
if(p_ui)
{
delete p_ui;
}
*/
if (UAV) {
delete UAV;
+20
View File
@@ -47,9 +47,29 @@ propertyui::propertyui(QWidget *parent) :
//根据当前点的属性设置界面
/*
property_quick = new QQuickWidget(this);
property_quick->setFocus();
property_quick->setResizeMode(QQuickWidget::SizeRootObjectToView);
property_quick->setAttribute(Qt::WA_AlwaysStackOnTop);
QUrl source(QUrl(QStringLiteral("qrc:/qml/propertyUI.qml")));
property_quick->setSource(source);
QObject *pRoot = (QObject*)property_quick->rootObject();
const QObjectList list = pRoot->children();
foreach(QObject *Item,list)//查找 CommandMsg 类,然后连接
{
if((QString)Item->metaObject()->className() == "CommandMsg fund")//找到 CommandMsg 类
{
qDebug() << Item->metaObject()->className() << Item->objectName();
//m_Command = static_cast<CommandMsg*>(Item);
}
}
*/
}
+26 -4
View File
@@ -8,17 +8,35 @@
#include "QJsonObject"
#include "QJsonParseError"
/*
#include "QQuickWidget"
#include "QQuickView"
#include "QtQml"
#include "qqml.h"
#include "QQmlEngine"
*/
#include "QDebug"
#ifdef QtopmapWidget
#include <mapwidgetglobal.h>
namespace Ui {
class OPMAPWIDGETSHARED_EXPORT propertyui;
}
class OPMAPWIDGETSHARED_EXPORT propertyui : public QWidget{
#else
namespace Ui {
class propertyui;
}
#ifdef QtopmapWidget
#include <mapwidgetglobal.h>
class OPMAPWIDGETSHARED_EXPORT propertyui : public QWidget{
#else
class propertyui : public QWidget{
#endif
Q_OBJECT
@@ -65,6 +83,10 @@ private:
static const char* _versionJsonKey;
Ui::propertyui *ui;
//QQuickWidget *property_quick = nullptr;
};
#endif // PROPERTYUI_H
+10 -10
View File
@@ -30,21 +30,21 @@
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QQuickWidget" name="property_quick">
<property name="resizeMode">
<enum>QQuickWidget::SizeRootObjectToView</enum>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QQuickWidget</class>
<extends>QWidget</extends>
<header location="global">QtQuickWidgets/QQuickWidget</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>