Answer the question
In order to leave comments, you need to log in
Why isn't drawing happening?
Hello.
There is a graphic scene, drawing with the mouse should take place in it.
But the application starts, but the line is not drawn. The compiler only issues a couple of warnings.
What's the catch?
#pragma once
#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QRectF>
#include <QPushButton>
#include <QGraphicsItem>
#include <QLineEdit>
#include <QMouseEvent>
class Paint : public QWidget
{
Q_OBJECT
public:
Paint(QWidget *parent = 0);
QGraphicsScene *scene;
QGraphicsView *view;
QPushButton *btn;
private:
QPointF previousPoint;
void mousePressEvent(QGraphicsSceneMouseEvent *e);
void mouseMoveEvent(QGraphicsSceneMouseEvent *e);
};
<code lang="cpp">
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
paint.cpp
HEADERS += \
paint.h
FORMS +=
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
</code>
Answer the question
In order to leave comments, you need to log in
Because the mousePressEvent and mouseMoveEvent functions are never called by anyone.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question