Results 1 to 8 of 8

Thread: How to delete ui member?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to delete ui member?

    Sorry for the late reply...

    The problem is that I want to use 2 separate, different forms in the same class.

    I can't create a "wrapper" widget, is there any way of excluding some objects from the children() list? If I use qDeleteAll(children()) then I want to prevent some of the objects from getting deleted, how would I do that? Can I treat it as a regular QList and use the negative (-) operator to remove certain objects? How would I do that? Would this work:

    Qt Code:
    1. QObject myPermanentObject;
    2. QObject myPermanentObject2;
    3. ...
    4. QObjectList childrenList = children();
    5. childrenList.removeAt(indexOf(myPermanentObject));
    6. childrenList.removeAt(indexOf(myPermanentObject2));
    7. ...
    8. qDeleteAll(childrenList);
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to delete ui member?

    Quote Originally Posted by codeslicer View Post
    The problem is that I want to use 2 separate, different forms in the same class.

    I can't create a "wrapper" widget
    Why would that be?

    Qt Code:
    1. {
    2. // setting up a common layout
    3. layout = new QVBoxLayout(this);
    4. layout->setMargin(0);
    5.  
    6. // creating common actions (which are not deleted when changing the form)
    7. QAction* action = new QAction(this);
    8. ...
    9. }
    10.  
    11. {
    12. // setting up form A
    13. wrapper = new QWidget(this);
    14. oneUi.setupUi(wrapper);
    15. layout->addWidget(wrapper);
    16. }
    17.  
    18. {
    19. // setting up form B
    20. wrapper = new QWidget(this);
    21. anotherUi.setupUi(wrapper);
    22. layout->addWidget(wrapper);
    23. }
    24.  
    25. {
    26. // cleaning up either form
    27. delete wrapper;
    28. }
    To copy to clipboard, switch view to plain text mode 

    Or just throw the whole complex idea away and start using QStackedWidget.
    J-P Nurmi

Similar Threads

  1. problem with forward declaration
    By MarkoSan in forum General Programming
    Replies: 14
    Last Post: 6th January 2008, 21:45
  2. Qtopia core 4.2.2 cross compile make error
    By smiyai18 in forum Installation and Deployment
    Replies: 2
    Last Post: 28th August 2007, 17:04
  3. Delete dialog
    By Krish_ng in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2007, 12:42
  4. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.