Results 1 to 2 of 2

Thread: allow user to draw n sided polygons in an open window

  1. #1
    Join Date
    Jun 2016
    Posts
    1
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X

    Default allow user to draw n sided polygons in an open window

    Hello, I am a very inexperienced with Qt and qml and programming in general. Can someone explain the best method for implementing a feature that would allow a user to draw a polygon in a window? i want it to be able to draw one straight line from one node to another and then eventually close the polygon. Thank you

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

    Default Re: allow user to draw n sided polygons in an open window

    Since you mentioned QML I assume we are talking about a QtQuick based UI.

    The easiest way for a custom UI component that does that is to derive from QQuickPaintedItem and implement mousePressEvent() such that it stores the mouse positions in a vector or list and then use these values in paint() to draw the polyline using the given QPainter.

    I would suggest to start with just drawing a fixed polyline to get to know how the QPainter API works inside the QQuickPaintedItem and how registering the item type as well as using it from QML works.

    Cheers,
    _

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

    bruceqtbeginner (8th June 2016)

Similar Threads

  1. Replies: 2
    Last Post: 14th January 2013, 08:07
  2. Replies: 2
    Last Post: 16th May 2011, 09:06
  3. Replies: 3
    Last Post: 23rd December 2010, 07:55
  4. Replies: 0
    Last Post: 10th September 2010, 14:23
  5. Restrict user to open the same file
    By vermarajeev in forum General Programming
    Replies: 33
    Last Post: 25th May 2007, 09:15

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.