Results 1 to 5 of 5

Thread: How can I draw on Qlabel

  1. #1
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default How can I draw on Qlabel

    I want to draw a shape on Qlabel but I can not draw anything in below code
    .How can I do it



    Qt Code:
    1. void MyPainter::paintEvent(QPaintEvent *event)
    2. {
    3. QPainter painter(ui.label);
    4. painter.setRenderHint(QPainter::Antialiasing, true);
    5. painter.setPen(QPen(Qt::black, 15, Qt::SolidLine, Qt::RoundCap,
    6. Qt::MiterJoin));
    7. painter.setBrush(QBrush(Qt::blue, Qt::DiagCrossPattern));
    8. painter.drawPie(80, 80, 400, 240, 60 * 16, 270 * 16);
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 4th August 2008 at 07:25. Reason: missing [code] tags

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I draw on Qlabel

    Please see the Image Viewer example in Qt Demos.

  3. #3
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I draw on Qlabel

    I don't want to draw image , for example I want to draw line or point or circle on Qlabel

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I draw on Qlabel

    Then see the Scribble example in Qt Demo (under Widgets section0

  5. #5
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I draw on Qlabel

    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..

Similar Threads

  1. Replies: 3
    Last Post: 17th July 2008, 07:43
  2. want to draw points in QGraphicsScene
    By ntp in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2008, 18:14
  3. QLabel ScaledContents ignored by style sheet?
    By WinchellChung in forum Newbie
    Replies: 3
    Last Post: 27th February 2008, 14:50
  4. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  5. QScrollArea display custom QLabel
    By spawnwj in forum Qt Programming
    Replies: 6
    Last Post: 6th December 2006, 03:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.