Results 1 to 3 of 3

Thread: drawText over a QPixmap

  1. #1
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default drawText over a QPixmap

    Hello All
    I am facing issue on drawText over a QPixmap. The error that gets displayed
    Qt Code:
    1. QPainter::begin: Paint device returned engine == 0, type: 2 (painting/qpainter.cpp:1734, bool QPainter::begin(QPaintDevice*))
    2. QPainter::setFont: Painter not active (painting/qpainter.cpp:4068, void QPainter::setFont(const QFont&))"
    To copy to clipboard, switch view to plain text mode 

    The code is given below
    Qt Code:
    1. QImage originalImg = QImage(frame->data[0],1280,700,frame->linesize[0],QImage::Format_RGB888).copy();
    2. qDebug()<<originalImg.size();
    3. pxmap.fromImage(originalImg);
    4. QPainter paint(&pxmap);
    5. paint.setFont(QFont("Arial"));
    6. paint.drawText(QPoint(200,200),"Test");
    To copy to clipboard, switch view to plain text mode 
    Last edited by kaml.mish; 20th January 2015 at 10:03. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: drawText over a QPixmap

    You are most lilely drawing on a null pixmap, i.e. "pxmap" is most likely empty.

    If you want "originalImg" in "pxmap" you need to assign the result of QPixmap::fromImage(), not discard it.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: drawText over a QPixmap

    The issue has been fixed

Similar Threads

  1. Replies: 4
    Last Post: 28th August 2008, 13:13
  2. Replies: 1
    Last Post: 21st August 2008, 07:44
  3. Replies: 5
    Last Post: 9th April 2007, 14:26
  4. DrawText ?
    By whitefurrows in forum Qt Programming
    Replies: 2
    Last Post: 14th February 2007, 21:08
  5. drawText (QT/E 2.3.10)
    By agaf in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 4th February 2006, 11:48

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.