PDA

View Full Version : How can I draw on Qlabel



validator
4th August 2008, 07:33
I want to draw a shape on Qlabel but I can not draw anything in below code
.How can I do it




void MyPainter::paintEvent(QPaintEvent *event)
{
QPainter painter(ui.label);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, 15, Qt::SolidLine, Qt::RoundCap,
Qt::MiterJoin));
painter.setBrush(QBrush(Qt::blue, Qt::DiagCrossPattern));
painter.drawPie(80, 80, 400, 240, 60 * 16, 270 * 16);

}

aamer4yu
4th August 2008, 07:42
Please see the Image Viewer example in Qt Demos.

validator
4th August 2008, 08:51
I don't want to draw image , for example I want to draw line or point or circle on Qlabel

aamer4yu
4th August 2008, 09:36
Then see the Scribble example in Qt Demo (under Widgets section0 ;) :)

salmanmanekia
4th August 2008, 09:58
Hi,
The first parameter of QPen object should be QBrush and in your code it seems to QColor
so replace Qt::Black by some thing such as QBrush(Qt::Black,Qt::SolidPattern)



painter.setPen(QPen(Qt::black, 15, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));


i hope it works..:)