beggingqt
26th September 2017, 11:20
I've made the simplest possible drawing App - four files.
I build this in the terminal with qmake; make
Sadly there is no output.
I've tried several things - all the suggestions that Mr Google made did not work
Here's the code:
mini.pro
QT += widgets
CONFIG += console
HEADERS = mini.h
SOURCES = mini.cpp main.cpp
main.cpp
#include <QApplication>
#include "mini.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Mini my;
my.show();
return app.exec();
}
mini.h
#ifndef MINI_H
#define MINI_H
#include <QWidget>
class Mini : public QWidget
{
Q_OBJECT
public:
Mini(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event) override;
};
#endif
mini.cpp
#include <QtWidgets>
#include <QDebug>
#include "mini.h"
Mini::Mini(QWidget *parent)
: QWidget(parent)
{
setWindowTitle(tr("Mini Graphics"));
resize(300, 200);
}
void Mini::paintEvent(QPaintEvent * )
{
QColor color;
QPainter painter(this);
qDebug() << "painting";
color.setHsv(100, 255, 191);
painter.setPen(color);
painter.drawLine(50, 50, 100, 150);
}
I build this in the terminal with qmake; make
Sadly there is no output.
I've tried several things - all the suggestions that Mr Google made did not work
Here's the code:
mini.pro
QT += widgets
CONFIG += console
HEADERS = mini.h
SOURCES = mini.cpp main.cpp
main.cpp
#include <QApplication>
#include "mini.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Mini my;
my.show();
return app.exec();
}
mini.h
#ifndef MINI_H
#define MINI_H
#include <QWidget>
class Mini : public QWidget
{
Q_OBJECT
public:
Mini(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event) override;
};
#endif
mini.cpp
#include <QtWidgets>
#include <QDebug>
#include "mini.h"
Mini::Mini(QWidget *parent)
: QWidget(parent)
{
setWindowTitle(tr("Mini Graphics"));
resize(300, 200);
}
void Mini::paintEvent(QPaintEvent * )
{
QColor color;
QPainter painter(this);
qDebug() << "painting";
color.setHsv(100, 255, 191);
painter.setPen(color);
painter.drawLine(50, 50, 100, 150);
}