Results 1 to 6 of 6

Thread: Getting coordinates of all QGraphicsItem s on a QGraphicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2020
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Getting coordinates of all QGraphicsItem s on a QGraphicsScene

    great. Is there a way you know of that i could store these coordinates in a text file on a separate line each, so my question would be how do I recognise where is the end of coordinates of 1 shape and begining of another?

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting coordinates of all QGraphicsItem s on a QGraphicsScene

    This is up to you - maybe separate them with a newline.

  3. #3
    Join Date
    Apr 2020
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Getting coordinates of all QGraphicsItem s on a QGraphicsScene

    yeah I know how to get the data into a file. What i don't know is since you are saying all of that data are valid coordinates to my 3 shapes drawn on my scene, then how would you distinguish where does for example the first shape and its respective coordinates end, and where does the set of coordinates for second shape begin? Because there is no way to tell from the Qlist I'm getting

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Getting coordinates of all QGraphicsItem s on a QGraphicsScene

    Your screenshot is hard to read, but it looks like it is a qDebug() dump of the QList of QGraphicsItem instances. This is not how you will write your list to a file. (Yes, I know you can direct QDebug output to a file, but it doesn't provide the information you want in a very useful format).

    You will write a loop, get each QGraphicsItem pointer from the list, determine its type(), coordinates, size, and whatever else your want. You then take all of that, format it into a QString, and write that QString to the file in a single line. The next item goes on the next line, and so forth.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 10
    Last Post: 15th November 2012, 14:13
  2. QGraphicsItem coordinates, again
    By d_stranz in forum Qt Programming
    Replies: 15
    Last Post: 20th June 2011, 21:10
  3. Replies: 7
    Last Post: 21st March 2010, 03:11
  4. Replies: 0
    Last Post: 24th November 2008, 08:52

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.