Results 1 to 5 of 5

Thread: FillRect with text

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    70

    Default FillRect with text

    Hi,

    I need to paint over an image a repeated text ( like "Demo Version" ) .
    In particular, this text need to be rotated.

    I think the easiest solution is to use the fillRect with a QBrush Qt::TexturePattern, but I work in a different thread ( not GUI ) and the fillRect crash cause
    Qt Code:
    1. QPixmap: It is not safe to use pixmaps outside the GUI thread
    To copy to clipboard, switch view to plain text mode 

    Any suggestions ?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: FillRect with text

    Any suggestions ?
    Yes, you must do your painting actions in the painEvent().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2009
    Posts
    70

    Default Re: FillRect with text

    Yes, I know this. But how ???

    I want to paint a text over a qimage , with a rotation. The text is a string that need to be repeated over the full image.

    For instance, the text which appeared in a print layout using a demo version of a software.

    I hope you can understand my bad english !

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: FillRect with text

    But how ???
    You have to overload the paintEevent() of the widget in which you want this.
    You do know what overloading is right?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FillRect with text

    You can paint of QImage (as opposed to QPixmap) in a thread. But then eventually you'll have to convert the image to a pixmap to display it and this has to be done in the main thread where you will have to follow what high_flyer described anyway.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. fillRect does not display anything?
    By Ishmael in forum Newbie
    Replies: 5
    Last Post: 30th September 2009, 20:03
  2. problem in painter fillRect
    By wagmare in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2009, 13:43
  3. Replies: 1
    Last Post: 3rd September 2008, 14:16
  4. Fading effect on QPainter fillrect()
    By smarinr in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2008, 21:57
  5. how to show fillRect() using mouseEvents??
    By thomasjoy in forum Qt Programming
    Replies: 9
    Last Post: 31st August 2007, 14:30

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.