Results 1 to 4 of 4

Thread: Painter not active

  1. #1
    bainedyal Guest

    Default Painter not active

    Hello all!
    I am new in QT C++ Programming and I hope to get some help here.
    I am trying to make a simple program with QT.

    My goal is to save the parameter of objects to a file and then to load these backwards from the file.

    The painting and save-function run without problems, but the load (desterilize) shows the following error messages:
    QPainter::setBrush: Painter not active
    QPainter:: pen: Painter not active
    QPainter::setPen: Painter not active
    QPainter::drawRects: Painter not active

    I have been trying for few days to eliminate these errors but without success.

    Here a snippet of my paintevent-funktion:

    Here is my whole project-code: bainedyal.de/painter.zip

    If you have any idea please contact me.

    Thank you!

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Painter not active

    Quote Originally Posted by bainedyal View Post
    Here a snippet of my paintevent-funktion:
    You forgot the snippet.

  3. #3
    Join Date
    Oct 2010
    Posts
    55
    Thanks
    1
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    9

    Default Re: Painter not active

    QPainter works on a QPaintDevice, and in the case of QWidget you can't paint from outside a paint event. I really don't see why you need to paint anything in 'deserialize', however.

    The way I understand it, you save the file by serializing the objects to a file stream (in 'serialize'). So, deserialize should do the opposite – that is, parse whatever data you read from the file according to the same rules and add objects correspondingly to the 'objects' vector. Then you simply call update() to repaint the widget (or rather, post an event that will be processed when the program returns to the main event loop).

  4. #4
    bainedyal Guest

    Default Re: Painter not active

    Hey!

    I have done it!

Similar Threads

  1. painter->setRasterOp()
    By shruthi in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2010, 07:13
  2. Convert to painter
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2010, 00:41
  3. Problem with Painter in Qt4.4.1
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 1st September 2008, 13:47
  4. how to use loadFromData in painter
    By sar_van81 in forum Qt Programming
    Replies: 18
    Last Post: 31st January 2007, 04:09
  5. Painter not active!
    By Caius Aérobus in forum Qt Programming
    Replies: 7
    Last Post: 30th March 2006, 15: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.