问题描述
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:63: error: expected identifier before numeric constant
None = 0,// invalid event
^~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:63: error: expected ‘}’ before numeric constant
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:63: error: expected unqualified-id before numeric constant
None = 0,// invalid event
^~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:295: error: ‘friend’ used outside of class
Q_ENUM(Type)
^~~~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:295: error: ‘constexpr const QMetaObject* const qt_getEnumMetaObject’ redeclared as different kind of symbol
Q_ENUM(Type)
^~~~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:295: error: ‘Type’ was not declared in this scope
Q_ENUM(Type)
^~~~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:295: error: ‘friend’ used outside of class
Q_ENUM(Type)
^~~~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:295: error: ‘constexpr const char* const qt_getEnumName’ redeclared as different kind of symbol
Q_ENUM(Type)
^~~~~~
/usr/include/i386-linux-gnu/qt5/QtCore/qcoreevent.h:295: error: ‘Type’ was not declared in this scope
Q_ENUM(Type)
我正在尝试检索用户空闲时间
尝试链接 this link 和 this link,但对我不起作用
我的个人资料
#-------------------------------------------------
#
# Project created by QtCreator 2021-05-01T07:53:43
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION,4): QT += widgets
LIBS += -lX11
TARGET = GlobalHook
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to kNow how to port your code away from it.
DEFInes += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so,uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFInes += QT_disABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONfig += c++11
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
主窗口.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTimer>
#include <QDebug>
#include <X11/extensions/scrnsaver.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
void StartLoop();
QTimer * timer;
~MainWindow();
private slots:
void on_btnStart_clicked();
void on_btnStop_clicked();
private:
Ui::MainWindow *ui;
display * m_display;
int m_EventBase,m_ErrorBase;
XScreenSaverInfo m_Info;
uint m_MSec;
};
#endif // MAINWINDOW_H
MainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),ui(new Ui::MainWindow)
{
ui->setupUi(this);
timer=new QTimer(this);
connect(timer,&QTimer::timeout,this,QOverload<>::of(&MainWindow::StartLoop));
}
void MainWindow::StartLoop()
{
if(XScreenSaverQueryExtension(m_display,&m_EventBase,&m_ErrorBase))
{
XScreenSaverQueryInfo(m_display,DefaultRootwindow(m_display),&m_Info);
m_MSec=(uint)m_Info.idle;
qDebug()<<"idle time"<<m_MSec;
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_btnStart_clicked()
{
timer->start(1000);
}
void MainWindow::on_btnStop_clicked()
{
timer->stop();
}
我的项目是创建一个用户监控应用程序,如果用户在固定时间内不使用键盘鼠标,则必须停止应用程序的某些部分。我成功地为 Windows 和 MacO 创建了它。 我用
为linux平台创建了它#define MOUSEFILE "/dev/input/event4"
#define MOUSEMOVEFILE "/dev/input/js1"
#define KEYBOARDFILE "/dev/input/event0"
以上方法。此方法在树莓派操作系统-桌面版中成功运行,但在ubantu中失败。
所以这就是为什么我在“
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)