Results 1 to 2 of 2

Thread: QPainter::setPen() painter not active

  1. #1
    Join Date
    Jan 2013
    Posts
    25
    Thanks
    2
    Platforms
    Windows

    Default QPainter::setPen() painter not active

    I have two scenarios.

    In first scenario: I added a QFrame in QWidget (acting as my mainwindow). I have a function drawline(). I call this function in QFrame:aintevent(). This works fine without any errors and lines are drawn.


    In the second scenario, I am drawing on a QFrame after receiving response from my server.
    My QFrame is add into MainWindow. When I call my draw function (outside QFrame's paintevent), I get the following errors:

    QPainter::begin: Paint device returned engine == 0, type: 1
    drawing lines w/o painter
    QPainter::setPen: Painter not active
    QPainter::setPen: Painter not active
    QPainter::setPen: Painter not active
    QPainter::setPen: Painter not active


    Can anyone help me in solving the problem?

    thanks

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QPainter::setPen() painter not active

    When I call my draw function (outside QFrame's paintevent),
    Painting should be done only in paintEvent() function or other functions called from paintEvent().

    BTW QPainter has to created with QWidget/QFrame as parent
    Last edited by Santosh Reddy; 29th August 2013 at 21:44.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    tesmai4 (30th August 2013)

Similar Threads

  1. Replies: 1
    Last Post: 21st March 2012, 05:58
  2. painter not active
    By athulms in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2011, 18:02
  3. Painter not active
    By bainedyal in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2011, 11:06
  4. Why painter->setPen() doesn't work with QTextDocument?
    By jiveaxe in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2007, 17:53
  5. Painter not active!
    By Caius Aérobus in forum Qt Programming
    Replies: 7
    Last Post: 30th March 2006, 16:44

Tags for this Thread

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.