Header:
Code: Alles auswählen
#ifndef FLOW_GRAPH_H
#define FLOW_GRAPH_H
#include <QImage>
#include <QLabel>
#include <QPainter>
#include <QScrollArea>
class FlowGraph : public QScrollArea
{
public:
FlowGraph();
QImage image;
QLabel *imageLabel;
protected:
void paintEvent(QPaintEvent *event);
};
#endif // FLOW_GRAPH_HCode: Alles auswählen
#include "flow_graph.h"
FlowGraph::FlowGraph()
{
imageLabel = new QLabel;
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);
this->setBackgroundRole(QPalette::Dark);
this->setWidget(imageLabel);
image = QImage(800, 200, QImage::Format_RGB32);
image.fill(0);
imageLabel->setPixmap(QPixmap::fromImage(image));
imageLabel->adjustSize();
}
void FlowGraph::paintEvent ( QPaintEvent * event )
{
QPainter painter(this);
painter.setPen(QPen(Qt::white,12,Qt::DashDotLine, Qt::RoundCap));
painter.setBrush(QBrush(Qt::green,Qt::SolidPattern));
painter.drawEllipse(80,80,400,240);
painter.drawImage(0, 0, image );
}Code: Alles auswählen
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
....