I have a single QMainWindow, which has a number of widgets, they have their frames, labels etc... ,but most importantly one QGraphicsView called test. I want it to respond when being clicked on, as I plan on creating "Paint"-like program. I can make mousePressEvent work for MainWindow:
void MainWindow::mousePressEvent(QMouseEvent *event)
{
//stuff
}
problem is, that it when I click anywhere within the program, but I cannot get to work same with QGraphicsView called test instead of MainWindow eg.:
void test::mousePressEvent(QMouseEvent *event)
{
//stuff
}
I get "test is not a class or namespace name" error. I have looked for solutions everywhere and my constructor DOES have ui->setupUi(this) at the very beggining and I also DO have ui included
#include "ui_mainwindow.h"
// some imore includes
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// stuff
}
I have no idea what am I missing here. I hope Im not doomed to checking where did mouse click through event pos() each time it clicks and whether it is in QGraphicsView boundaries, as I also plan to let user click on a few other QWidgets.
Thanks in advance
EDIT: declaration of test (auto-created by Qt, was in ui_mainwindow.h):
test = new QGraphicsView(centralWidget);
test->setObjectName(QStringLiteral("test"));
test->setDragMode(QGraphicsView::NoDrag);
also, centralWidget is child of MainWindow, so its: MainWindow->centralWidget->test
EDIT2: I also have Q_OBJECT in header and I have tryied using Q_SLOTS