You pass an uninitialized pointer for the Q3CanvasView() constructor.
main.cpp
#include <QApplication>
#include "canvassample.h"
int main(int argc, char *argv[])
{
CanvasSample s;
s.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
#include <QApplication>
#include "canvassample.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CanvasSample s;
s.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
To copy to clipboard, switch view to plain text mode
canvassample.h
#ifndef CANVASSAMPLE_H
#define CANVASSAMPLE_H
#include <Q3CanvasView>
class CanvasSample : public Q3CanvasView
{
Q_OBJECT
public:
CanvasSample();
~CanvasSample();
};
#endif // CANVASSAMPLE_H
#ifndef CANVASSAMPLE_H
#define CANVASSAMPLE_H
#include <Q3CanvasView>
class CanvasSample : public Q3CanvasView
{
Q_OBJECT
public:
CanvasSample();
~CanvasSample();
};
#endif // CANVASSAMPLE_H
To copy to clipboard, switch view to plain text mode
canvassample.cpp
#include <QPixmap>
#include <Q3Canvas>
#include "canvassample.h"
CanvasSample::CanvasSample() : Q3CanvasView()
{
setCanvas(new Q3Canvas(pixmap.width(),pixmap.height()));
canvas()->setBackgroundColor(Qt::black);
canvas()->setBackgroundPixmap(pixmap);
}
CanvasSample::~CanvasSample()
{
}
#include <QPixmap>
#include <Q3Canvas>
#include "canvassample.h"
CanvasSample::CanvasSample() : Q3CanvasView()
{
QPixmap pixmap("stars.png");
setCanvas(new Q3Canvas(pixmap.width(),pixmap.height()));
canvas()->setBackgroundColor(Qt::black);
canvas()->setBackgroundPixmap(pixmap);
}
CanvasSample::~CanvasSample()
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks