'我目前在尝试编译该程序时遇到问题。该程序应该在 GUI QWidget 上显示鼠标的坐标错误在 mainwindow.cpp 文件的第 6 行'
//header
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QApplication>
#include <QMainWindow>
#include <QMouseEvent>
#include <QMessageBox>
#include <QWidget>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
void mouseReleaseEvent(QMouseEvent * event);
~MainWindow();
private:
Ui::MainWindow *ui;
QMessageBox *msgBox;
};
#endif // MAINWINDOW_H
'主窗口.cpp 文件'
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow()
{
MainWindow::mouseReleaseEvent (QMouseEvent * event);
}
void MainWindow::mouseReleaseEvent(QMouseEvent * event)
{
msgBox = new QMessageBox();
msgBox -> setWindowTitle("Coordinates");
msgBox -> setText("You released the button");
msgBox -> show();
}
MainWindow::~MainWindow()
{
delete ui;
}
'主要.cpp'
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow *w = new MainWindow();
w->setWindowTitle(QString::fromUtf8("QT-capture mouse release"));
w->resize(300, 250);
w->show();
return a.exec();
}
请帮忙,我知道它与指针和可能的变异器有关,但我还看不到它。谢谢你。