我已经创建了两组头文件和源文件,它们通过使用Qt5读取全局鼠标指针坐标( libxdo无法读取),它通过数学计算速度,当鼠标指针的速度超过阈值时,它应该显示唯一的Qt窗口。
另一组头和源抓取(钩子)并侦听全局键盘事件,当按下键组合时,项目在后台运行,Qt窗口(在我与它集成后)被隐藏。我输入的任何内容都存储在一个文件中,直到我按下[ESC]。
现在,Qt窗口应该只出现在我移动鼠标指针超过一定速度时,文本应该显示在那里。
如果我在输入鼠标时移动了鼠标,窗口就会出现,并且我可以看到正在QWindow中写入的文本。但当我再次移动鼠标时,它应该被隐藏起来。
我不会将libqxt用于qt5,上面的程序应该在系统的i logout之前运行。使用Ubuntu 16.04。
我试着在main.cxx里这样做:
#include <QApplication>
#include "mainwindow.hpp"
#include <QDesktopWidget>
#include <QMetaObject>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
MainWindow window;
int width = QApplication::desktop()->width(), height = QApplication::desktop()->height();
window.setGeometry ((width - 0.75 * width),height - 20, (width/2) , 10);
window.setWindowFlags (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
window.hide();
QMetaObject::invokeMethod( this, "keygrab", Qt::QueuedConnection, Q_ARG() );
QMetaObject::invokeMethod( this, "mousevelocity", Qt::QueuedConnection, Q_ARG() );
return app.exec();
}但是我完全搞砸了这个Qt应用程序的libx11 and libxdo成员和mainwindow.cxx中的函数,我不知道什么是最好的方法而不是这个,或者如果它是最好的,那么作为I have multiple main functions with multiple infinite loop for the keygrab and the mousepointer. I can't call them from the main of Qt application and even the above code runs the application first and then invoke them but I need the reverse way,我有一个问题。抱歉,第一次。
发布于 2017-12-10 22:00:10
我不能百分之百肯定我能理解你的问题,但是根据问题的标题和一些评论,以下是一些建议:
QProcess和朋友的例子。基本上,在启动应用程序时,应用程序使用一个特殊的命令行参数启动自身的第二个实例,该命令行参数告诉第二个子进程进入后台。然后父进程将退出,将子进程留在后台运行。QTimer并轮询事件所需的任何接口。https://stackoverflow.com/questions/47670254
复制相似问题