代码拉取完成,页面将自动刷新
#include "mainwindow.h"
#include "commandlinemanager.h"
#include <QApplication>
#include <QFile>
#include <QStringList>
#include <QWindow>
#include <QDebug>
#include <X11/Xlib.h>
int main(int argc, char *argv[])
{
auto envType = qEnvironmentVariable("XDG_SESSION_TYPE");
if (envType.contains("wayland")) {
qInfo() << QDateTime::currentDateTime().toString() << "notes:change wayland to xcb for QT_QPA_PLATFORM.";
qputenv("QT_QPA_PLATFORM", "xcb");
}
QApplication a(argc, argv);
CommandLineManager::instance()->process(a.arguments());
if (CommandLineManager::instance()->isSet("window-id")) {
QString windowId = CommandLineManager::instance()->value("window-id");
WId windowHwnd = WId(windowId.toULongLong());
QWindow *window = QWindow::fromWinId(windowHwnd);
if (!window) {
qDebug() << "Error:not found QWindow by window id:" << windowId;
return -1;
}
MainWindow w;
w.setProperty("_q_embedded_native_parent_handle", QVariant(windowHwnd));
w.winId();
w.windowHandle()->setParent(window);
Display *display = XOpenDisplay(nullptr);
if (!display) {
qWarning() << "can not connect xservice.";
return -1;
}
Window windowXID(windowHwnd);
XWindowAttributes attr;
XGetWindowAttributes(display, windowXID, &attr);
w.setGeometry(QRect(0, 0, attr.width, attr.height));
w.show();
return a.exec();
}
else {
MainWindow w;
w.show();
return a.exec();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。