代码拉取完成,页面将自动刷新
#include "mymainwindow.h"
#include "ui_mymainwindow.h"
#include <QPalette>
#include <QBrush>
#include <QQmlEngine>
#include <QQmlContext>
#include "mylisten.h"
#include <QDir>
MyMainWindow::MyMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowFlags(windowFlags() | Qt::SubWindow | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground);
setAutoFillBackground(true);
QPalette palette;
palette.setBrush(QPalette::Window, QBrush(Qt::transparent));
setPalette(palette);
ui->quickWidget->engine()->rootContext()->setContextProperty("widget", this);
ui->quickWidget->engine()->rootContext()->setContextProperty("currentPath", QDir::currentPath());
// ui->quickWidget->engine()->rootContext()->setContextProperty("MyListen", &MyListen::instance());
mousePointChanged();
ui->quickWidget->setClearColor(QColor(Qt::transparent)); //qml 透明
ui->quickWidget->setSource(QUrl("qrc:/main.qml"));
connect(&MyListen::instance(), &MyListen::mousePointChanged, this, &MyMainWindow::mousePointChanged);
setSystemMenu();
setFixedSize(ui->quickWidget->size());
}
MyMainWindow::~MyMainWindow()
{
delete trayIcon;
delete ui;
}
//添加系统托盘
void MyMainWindow::setSystemMenu()
{
trayIcon = new QSystemTrayIcon();
trayIcon->setIcon(QIcon(":/logo.ico"));
QMenu *menu = new QMenu();
action_exit = menu->addAction("quit");
connect(action_exit,SIGNAL(triggered(bool)),this,SLOT(systemExit(bool)));
trayIcon->setContextMenu(menu);
trayIcon->show();
}
void MyMainWindow::systemExit(bool)
{
qApp->quit();
}
void MyMainWindow::mousePointChanged()
{
QPoint p = MyListen::instance().mousePoint();
move(p.x()+5, p.y()+5);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。