Results 1 to 4 of 4

Thread: How to place a QPainter element in QML Rectangle?

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default How to place a QPainter element in QML Rectangle?

    There is a diagram which I have drawn with QPainter.
    How do I diaplay it in QML's Rectangle?

    That diagram will get updated on the runtime.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: How to place a QPainter element in QML Rectangle?

    You have two options:

    1) Draw into an image/pixmap and use a QtQuick Image element to display it. You will need your own QDeclarativeImageProvider subclass for that.

    2) Create your own QDeclarativeItem subclass, implement paint() and register your class as a new element.

    Cheers,
    _

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

    TheIndependentAquarius (19th October 2013)

  4. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to place a QPainter element in QML Rectangle?

    Thanks for the helpful post.

  5. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: How to place a QPainter element in QML Rectangle?

    Side note, don't forget to call setFlag(ItemHasNoContents, false); in order to show an item's content.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. How to draw a QPainter rectangle over Widgets
    By sureshdharmadurai in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2011, 11:17
  2. right click QPainter rectangle?
    By mattyev87 in forum Newbie
    Replies: 6
    Last Post: 27th January 2011, 14:22
  3. Replies: 0
    Last Post: 11th November 2010, 21:21
  4. how to draw columns in QPainter's rectangle
    By jyoti in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2007, 11:50
  5. Draw a rectangle alternating two colors with qPainter
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2006, 00:12

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.