配置(目前我从我的公司获得的版本越多):
- Qt 5.12
- Red Hat 7.9 Linux server
- GCC 4.8.5
我正在开展一个项目,在这个项目中,窗户的所有权线可以像我所希望的那样实现个人化(增加原木,更新纽特权......)。 因此,我创造了一个无情的传彩礼(有Qt.FramelessWindowHint和Qt.Window旗),并在顶上添加了一条我所希望的所有其他内容。
但是,如果没有窗户的原始所有权条码,我只能把窗户移走。 因此,我补充说,“MouseArea”填补了我的空白,并计算了窗口的新位置,如:
The main.qml
:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
ApplicationWindow
{
id: mainWindow
property int previousX: 0
property int previousY: 0
property bool isFullScreen: false
visible: true
visibility: Qt.Window
title: ""
minimumWidth: 1400
minimumHeight: 900
flags: Qt.Window | Qt.FramelessWindowHint
Rectangle
{
id: mainWindowTitleBar
anchors
{
top: parent.top
left: parent.left
right: parent.right
}
width: parent.width
height: 30
color: "white"
z: 1
MouseArea
{
id: mouseAreaToChangePosition
anchors.fill: parent
onPressed:
{
previousX = mouseX
previousY = mouseY
}
onMouseXChanged:
{
var dx = mouseX - previousX
mainWindow.setX(mainWindow.x + dx)
}
onMouseYChanged:
{
var dy = mouseY - previousY
mainWindow.setY(mainWindow.y + dy)
}
onDoubleClicked:
{
if (isFullScreen)
{
mainWindow.visibility = Qt.WindowMinimized
}
else
{
mainWindow.visibility = Qt.WindowFullScreen
}
isFullScreen = !isFullScreen
}
}
}
}
改为<代码>main.cpp:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
int main(int argc, char *argv[])
{
try
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl("qrc:/main.qml"));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
catch(const std::exception& ex)
{
// Handle any exceptions that might occur during application execution
qDebug().noquote() << "Error: " << ex.what();
return 1;
}
}
But, doing this, the move is not correct for me, because I can t "hide" half the window dragging it on the border of the screen. The minimum and maximum position accepted are the ones for which the application is fully display on screen.
是否有可能以任何方式直接叫“女权者”来进一步履行这一职能? 我在互联网上看到在QML中暴露QGuiApplication,但我不知道如何派有新立场的活动。
提前感谢。