Results 1 to 18 of 18

Thread: How to move an item on a GraphicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    I did it, but there's no change, nothing moves.

    can someone post me an example that works please?
    what i want is to move the item upper in the vertical direction.
    thanks for help.

  2. #2
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    it works now! thanks very much for the last idea!
    but there's another problem, the item is moving down. How can i get it moving up first and then moving down and the movement should be inside the lines (i mean the item should remain inside the lines when moving) .
    thanks for your help.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to move an item on a GraphicsScene

    Quote Originally Posted by Holy View Post
    but there's another problem, the item is moving down. How can i get it moving up first and then moving down and the movement should be inside the lines
    The movement is controlled by the animation object:
    Qt Code:
    1. for( int i = 0; i < 50; ++i ) {
    2. anim.setTranslationAt( i / 100.0, 0, i );
    3. }
    4. for( int i = 50; i < 100; ++i ) {
    5. anim.setTranslationAt( i / 100.0, 0, 50 - i );
    6. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    thanks for your reply;
    i have another problem , while inserting items in the scene all items are added at the same time but not one after another like i want them to be added, i've tried to controll this adding action of the scene by controlling the QTimeLine of Container :

    something like this:
    the variable QTimeLine timeline is declared public in the class container; i use it to controll the animation of the containers.
    Qt Code:
    1. void MainGui::addnextContainer(int i, QGraphicsScene *scene1)
    2. {
    3. for(int i=0;i<containerNum; i++)
    4. {
    5. Container*[i];
    6. scene1->addItem(c[i]);
    7. c[i]->timeline->start();
    8. c[i+1]->timeline->setPaused(true);
    9. l_items(c[i]);
    10. c[i]->timeline->stop();
    11. scene1->addItem(c[i+1]);
    12. c[i+1]->timeline->start();
    13. l_items()
    14.  
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    puting the items in a range in the scene

    Qt Code:
    1. QList<QGraphicsItem*>MainGui:: l_items(QGraphicsItem *item1)
    2. {
    3. QList<QGraphicsItem*>listing=scene->items();
    4. listing.clear();
    5. for(int i=0; i<listing.size();i++)
    6. {
    7. listing.append(item1);
    8.  
    9. }
    10. return listing;
    11. }
    To copy to clipboard, switch view to plain text mode 
    and i changed the MainGui.cpp
    Qt Code:
    1. ...
    2. Scene scene= new Scene(this);
    3. addnextContainer(5, scene)
    4. ...
    To copy to clipboard, switch view to plain text mode 
    can someone take a look at this code and tell me please what i'm doing wrong please? now i even cannot see any item anymore.
    thanks in advance
    Last edited by jpn; 17th June 2008 at 15:16. Reason: missing [code] tags

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to move an item on a GraphicsScene

    What is l_items() method supposed to do? Now it just returns an empty list.

  6. #6
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    apology for the late reply, i did something else as i didn't get the solution of this problem.
    back to your question.
    the l_items() method is supposed to list the containers objects which are added to the scene. Can you also help me by controlling the addItem() method so that the containers should be added one by one and not all at the same time?
    thanks in advance.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to move an item on a GraphicsScene

    Quote Originally Posted by Holy View Post
    the l_items() method is supposed to list the containers objects which are added to the scene.
    Lines 5--9 are never executed because you clear the list in line 4.

    Quote Originally Posted by Holy View Post
    Can you also help me by controlling the addItem() method so that the containers should be added one by one and not all at the same time?
    What do you mean by "one by one"? Do you want to have some kind of animation?

  8. #8
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    the items are already animated and it works very well, but what i need now is to get control over the addItem() method of scene, so that when i add n items in the scene for instance, i should get them added one after another and not as a group of n added of course as animation.
    i also tried to remove listing.clear() completely but it doesn't do anything different.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to move an item on a GraphicsScene

    Quote Originally Posted by Holy View Post
    the items are already animated and it works very well, but what i need now is to get control over the addItem() method of scene, so that when i add n items in the scene for instance, i should get them added one after another and not as a group of n added of course as animation.
    Would it be enough if there was some delay between calls to addItem()?

    Quote Originally Posted by Holy View Post
    i also tried to remove listing.clear() completely but it doesn't do anything different.
    Better rewrite that method from scratch.

  10. #10
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    From Guru:Would it be enough if there was some delay between calls to addItem()?

    i don't understand what you mean , can you please send me the example code to compile myself and see what you exactly mean with"some delay between calls to addItem()"

    I have another question concerning Qt4.3 Network. There is an example named :"blockingFortuneclient" , i've tried to run that with eclipse on window(vista) but i cannot run it succesfully. wenn i try to input a port number it breaks, i mean it doesn't enable to input the port number.Can someone tell me please what is the problem.

    Another question is : can i implement a middleware of RFID-System in the same way as this example to receive Data from a RFID-Reader?
    or does someone know how to implement an RFID-receiver with Qt ? i will be very thankfull if someone send me an example code.
    thanks for your reply.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to move an item on a GraphicsScene

    Quote Originally Posted by Holy View Post
    From Guru:Would it be enough if there was some delay between calls to addItem()?
    As a result user would see that one item appears on the scene, after a while another one appears, then another and so on. Is that what you want by writing "one after another"?

    Quote Originally Posted by Holy View Post
    what you exactly mean with"some delay between calls to addItem()
    In Qt applications you usually add delay with QTimer.

    Quote Originally Posted by Holy View Post
    I have another question concerning Qt4.3 Network. There is an example named :"blockingFortuneclient" , i've tried to run that with eclipse on window(vista) but i cannot run it succesfully. wenn i try to input a port number it breaks, i mean it doesn't enable to input the port number.Can someone tell me please what is the problem.
    What "breaks" mean in exactly this case? Does the application crash or it starts properly but you can't enter anything into line edits?

    Quote Originally Posted by Holy View Post
    Another question is : can i implement a middleware of RFID-System in the same way as this example to receive Data from a RFID-Reader?
    Everything depends on the RFID reader and its drivers. Some readers have USB or RS-232C interfaces and for these you don't need any networking code.

    Next time please ask unrelated questions in new threads.

  12. #12
    Join Date
    May 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move an item on a GraphicsScene

    Guru
    As a result user would see that one item appears on the scene, after a while another one appears, then another and so on. Is that what you want by writing "one after another"?
    Holy:
    it's exactly what i mean .
    Guru:
    In Qt applications you usually add delay with QTimer.
    Holy:
    Isn't it possible with QTimeLine? can i get an example please?
    Guru:
    What "breaks" mean in exactly this case? Does the application crash or it starts properly but you can't enter anything into line edits?
    Holy: I don't know what the problem was, i've just closed Eclipse and now it's alright,it's working again.
    Thanks for your answer.

Similar Threads

  1. Move and resize with layout
    By waediowa in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2008, 08:16
  2. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  3. Replies: 1
    Last Post: 19th April 2007, 22:23
  4. how to display full tree item name on mouse move ?
    By rajesh in forum Qt Programming
    Replies: 5
    Last Post: 15th November 2006, 08:41
  5. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 01:34

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.