Results 1 to 5 of 5

Thread: background painting in the Scene

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default background painting in the Scene

    Hi,

    I have a question about some painter behaviour.
    I have overloaded the the drawBackground for my scene. When a user sets m_draw flag to true some text should be drawn:
    Qt Code:
    1. void GScene::drawBackground(QPainter *painter, const QRectF &rect)
    2. {
    3. ....some drawing
    4. if(m_draw)
    5. {
    6. painter->drawText(QPointF(0,0),"Text");
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    But the "Text" is not drawn. When I invalidate the scene and (m_draw==TRUE), while debugging, I see that the code is invoked, but nothing is drawn. In the console nothing is printed, no warning, no error.

    Thanks for any help.

    P.S.

    I have also tried this, and it works...
    Qt Code:
    1. ....
    2. if(1)
    3. {
    4. if(1)
    5. {
    6. painter->drawText(QPointF(0,0),"Text2");
    7. }
    8. }
    9. .....
    To copy to clipboard, switch view to plain text mode 
    Last edited by maverick_pol; 7th January 2008 at 18:57.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: background painting in the Scene

    What color are the text and the background?
    Maybe the scene coordinate (0,0) is outside the view...

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: background painting in the Scene

    Hi,

    For 100% the color is ok. To proove it I have done this and get the "Text1" at the (0,0), but still no text2.

    Qt Code:
    1. ....
    2. painter->drawText(QPointF(0,0),"TExt1");
    3. if(m_draw) /(*!< m_draw for 100% equals true*/
    4. {
    5. painter->drawText(QPointF(0,0),"Text2");
    6. }
    7. ....
    To copy to clipboard, switch view to plain text mode 

    That's a bit strange.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: background painting in the Scene

    Then the problem must be with the boolean variable.
    Do you modify it from other threads?

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: background painting in the Scene

    Ok,

    Sorry for misleading a bit. I have found the mistake. I have been invalidating a rect which was to small.

    Thank you for help

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

Similar Threads

  1. Creating new scene from a part of an old one
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 28th November 2007, 18:14
  2. Painting directly on the scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2007, 13:55
  3. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  4. How to use QGraphicsView and Scene right ...
    By Mike in forum Qt Programming
    Replies: 6
    Last Post: 22nd January 2007, 08:51
  5. Replies: 1
    Last Post: 5th April 2006, 16:44

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.