tommy
9th November 2007, 19:16
Hello,
I'm experimenting with QPainter and I'm able to draw simple primitives. The trouble starts when I want to add my drawing to my main layout (mainLayout->addWidget(l);). Is it true that you can't just add your drawing to your layout as a QLabel widget? Do I have to declare a new class and draw on a widget? I use mingw.
//THIS DOESN'T WORK:
//error: 'setPixmap' has not been declared
//error: request for member of non-aggregate type before '(' token
#include <QtGui>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget window;
QVBoxLayout* mainLayout = new QVBoxLayout(&window);
QPixmap pm(100,100);
pm.fill();
QPainter p(&pm);
QPen pen(Qt::blue, 1);
p.setPen(pen);
p.drawEllipse(0,0,80,80);
QLabel* l;
l.setPixmap(pm);
mainLayout->addWidget(l);
window.show();
return app.exec();
}
I'm experimenting with QPainter and I'm able to draw simple primitives. The trouble starts when I want to add my drawing to my main layout (mainLayout->addWidget(l);). Is it true that you can't just add your drawing to your layout as a QLabel widget? Do I have to declare a new class and draw on a widget? I use mingw.
//THIS DOESN'T WORK:
//error: 'setPixmap' has not been declared
//error: request for member of non-aggregate type before '(' token
#include <QtGui>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget window;
QVBoxLayout* mainLayout = new QVBoxLayout(&window);
QPixmap pm(100,100);
pm.fill();
QPainter p(&pm);
QPen pen(Qt::blue, 1);
p.setPen(pen);
p.drawEllipse(0,0,80,80);
QLabel* l;
l.setPixmap(pm);
mainLayout->addWidget(l);
window.show();
return app.exec();
}