Results 1 to 13 of 13

Thread: Probelm after porting from Qt 3.3.4 to Qt 4.2.2

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Probelm after porting from Qt 3.3.4 to Qt 4.2.2

    Yes, my solution is somewhat particular.
    This does not mean that there isn't a general one.
    Unfortunately I am at work now, but I'll be happy to help once I'm done here.

    Regards

  2. #2
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Probelm after porting from Qt 3.3.4 to Qt 4.2.2

    Quote Originally Posted by marcel View Post
    Yes, my solution is somewhat particular.
    This does not mean that there isn't a general one.
    Unfortunately I am at work now, but I'll be happy to help once I'm done here.

    Regards
    Waiting eagerly....
    Thanks..

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Probelm after porting from Qt 3.3.4 to Qt 4.2.2

    Hi,
    here's a suggestion:
    Qt Code:
    1. void Molecule::deleteSelected()
    2. {
    3. if( isSelected ){
    4. deleteLater();
    5. return;
    6. }
    7.  
    8. foreach( Bond *bond, findChildren<Bond*>() )
    9. bond->deleteSelected();
    10. }
    To copy to clipboard, switch view to plain text mode 
    In this case you are not iterating and deleting the children list(dangerous!), but you are implicitely working on a copy.
    Also you can remove the setName() calls, since you are only using the class names. You can get to them by calling QMetaObject::className()

  4. #4
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Probelm after porting from Qt 3.3.4 to Qt 4.2.2

    Consider this scenario...

    Suppose there are 5 bonds( bond1, .... bond5), from the foreach statement,
    Now
    1) First Iteration leads to deletion of bond1 and bond3;
    2) Second iteration works fine.
    3) Third iteration, OH!!! Crashes, the bond is already deleted in
    iteration1.

    Fails...
    Please provide some solution where the list gets updated
    automatically like how it worked in Qt3.

    Please run the same code without any changes in Qt3 (provided in first post) and then
    run again the same code after porting to Qt4, you
    can find the differences..

    Please help

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.