Results 1 to 6 of 6

Thread: QML extension - painting issue

  1. #1
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default QML extension - painting issue

    Hi again,

    I am looking for a simple way to draw several rectangles (the amount depends on user). This could be quite simple, but I would like to have all these rectangles placed on the circle with specific radius. Apart from that each rectangle will contain text, and may contain icon image.

    My main concern, as I've never done things like this, is to how
    - draw the rectangle with text and icon inside of it
    - how to put all these rectangles on the circle.

    I think I should at first draw transparent circle which would be parent for all rectangles, therefore rectangles should be parents for text and icon inside of them, am I right ?
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

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

    Default Re: QML extension - painting issue

    Quote Originally Posted by kornicameister View Post
    - draw the rectangle with text and icon inside of it
    Create a Rectangle Element with two children -- one for the icon and one for the text and anchor them to the parent.

    - how to put all these rectangles on the circle.
    That's quite simple. Write javascript code that will calculate x and y positions for different angles of the circle. Then instantiate your rectangles dynamically and place them in the calculated coordinates.The math involves calculating position of a point on a sloped line with distance equal to the radius of the circle (there is a right triangle there so it boils down to using sine or cosine).
    Last edited by wysota; 3rd October 2011 at 09:20.
    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.


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

    kornicameister (5th October 2011)

  4. #3
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QML extension - painting issue

    I wanted to make it in C++ code, but it seems that making it in QML code would be more flexible because these rectangles could be placed on any shape I would like to place them. Nevertheless the approach will be the same, even I want to implement such feature in C++.
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

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

    Default Re: QML extension - painting issue

    You can do the same thing in C++. I had the impression you wanted to do that in QML
    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.


  6. #5
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QML extension - painting issue

    Now, after you've mentioned that, I am pretty confused where I would like to put it...

    but I think that would be simpler do draw single Rectangle and than already in QML code attach to any shape I want to.
    Basically I have a class which uses QDeclarativeListProperty and I am constantly thinking whether I should put all drawing inside this class which uses QDeclarativeListProperty or rather to the type T which is placed in QDeclarativeListProperty.
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  7. #6
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QML extension - painting issue, qmldump issue

    please remove this post
    I decided to moved it's content to new thread
    Last edited by kornicameister; 5th October 2011 at 10:24.
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

Similar Threads

  1. QMake Target extension
    By gregg in forum Qt Tools
    Replies: 2
    Last Post: 28th February 2011, 18:18
  2. QScrollArea and Painting issue
    By myfifth in forum Newbie
    Replies: 4
    Last Post: 21st January 2011, 08:21
  3. using qmotif extension
    By pascasio in forum Newbie
    Replies: 7
    Last Post: 30th November 2010, 13:53
  4. Using Qt with kernel extension dll
    By ramazangirgin in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2008, 13:23
  5. QListWidget painting issue
    By guilugi in forum Qt Programming
    Replies: 6
    Last Post: 16th April 2007, 17:06

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.