Results 1 to 4 of 4

Thread: Ownership of the QPointf that are created with new appended in QList<QPointf> list

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2017
    Posts
    23
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Ownership of the QPointf that are created with new appended in QList<QPointf> list

    I have a QList<QPOintf> that has 10 element inside it, i want to copy the list in a reverse order then append it again to the list but this is done after changing the y value of QPointf. For example:

    suppose our list is as follow:
    Qt Code:
    1. m_resultPoints has the following points [(1,2),(1,3),(5,6),(7,2),(3,4),(7,9),(4,5),(2,0),(2,4),(4,7)];
    To copy to clipboard, switch view to plain text mode 
    I want it to be:
    Qt Code:
    1. m_resultPoints should have the following points [(1,2),(1,3),(5,6),(7,2),(3,4),(7,9),(4,5),(2,0),(2,4),(4,7),(4,-7),(2,-4),(2,-0),(4,-5),(7,-9),(3,-4),(7,-2),(5,-6),(1,-3),(1,-2)];
    To copy to clipboard, switch view to plain text mode 
    So I put the list in a loop and created a QPointf dynamically using new operator and appended it to the list content. Now who take the owner ship of the points, i think it is the QList, am i right ?
    I also wonder if there is another way to do this in more elegant way, thanks in advance.

    Here is the code snippet that is used to do the appending and the reversing of the list points:
    Qt Code:
    1. for (int i = 0; i < m_resultPoints->size(); ++i) {
    2. m_resultPoints->append(*new QPointF(m_resultPoints->at(m_resultPoints->size()-i).x() , (-1*m_resultPoints->at(m_resultPoints->size()-i).y() )));
    3. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Ahmed Abdellatif; 14th September 2018 at 14:23.

Similar Threads

  1. QPointF - draw only 30% of window
    By pajczur in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2017, 13:26
  2. Using QPointF in QShareData class
    By SasaVilic in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2010, 00:33
  3. QPointF == operator usage
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2010, 08:41
  4. QPointF equality operator
    By jenova_project in forum Newbie
    Replies: 1
    Last Post: 22nd September 2008, 16:42
  5. QPointF transformation
    By dreamer in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 10:11

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.