Results 1 to 6 of 6

Thread: reading integers from QTextEdit doesn't go right ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: reading integers from QTextEdit doesn't go right ?

    Thanks the spinner trick worked just fine ... the painter.save() line it holds the current shapes drawn , when I remove this line and call the draw method it erases previous shapes

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: reading integers from QTextEdit doesn't go right ?

    QPainter::save() saves the current state of the painter not the painted device. That state is stored internally to the QPainter and can only live as long as the QPainter exists, which in this case is until the end of the paintEvent(). You never call QPainter::restore() so the saved states are never reused.

    Subsequent calls to the paintEvent() only draw the shape associated with the last clicked button because that is the logic you have implemented by clearing the px flag after drawing the shape x.

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

    mernarezk (2nd December 2013)

  4. #3
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: reading integers from QTextEdit doesn't go right ?

    No the Px flags are not the problem, I searched and I should use the painter on a painting device like a PixMap or anything like canvas in java but I am have no idea how to use them, so any idea how can I overcome the problem that painter deletes previous shapes when trying to draw a new one ? ...one more question is there anyway to invert my axis ? x=0 , y=0 are at the top left corner is it possible to make them like cartesian coordinates x,y=0,0 at the botton left cornor ?

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: reading integers from QTextEdit doesn't go right ?

    If you want to accumulate a set of marks on the page then you need to keep a persistent track of either the page or the actions required to draw it. I suggest you spend some time with the Scribble Example, particularly the ScibbleArea class.

    For the axis reversal:
    Coordinate System: Transformations
    QPainter::scale() with a negative scale in the Y direction.

Similar Threads

  1. add two integers
    By Gishan in forum Newbie
    Replies: 3
    Last Post: 8th September 2012, 08:44
  2. QTextEdit doesn't append text
    By Luc4 in forum Qt Programming
    Replies: 7
    Last Post: 13th June 2010, 22:45
  3. Only integers from QFontMetricsF width
    By StevenB in forum Qt Programming
    Replies: 3
    Last Post: 16th May 2008, 21:59
  4. how to get integers from mysql
    By eleanor in forum Qt Programming
    Replies: 9
    Last Post: 8th November 2007, 16:25
  5. reading QTextEdit from file
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 29th March 2006, 21:45

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
  •  
Qt is a trademark of The Qt Company.