Results 1 to 8 of 8

Thread: setCentralWidget() without deleting prev widget

Threaded View

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

    Default setCentralWidget() without deleting prev widget

    Hello. Sorry for my bad english..

    How can I call setCetralWidget() that previous widget wasn't deleted?

    it is the realization of setCentralWidget():
    void QMainWindow::setCentralWidget(QWidget *widget)
    1. {
    2. Q_D(QMainWindow);
    3. if (d->layout->centralWidget() && d->layout->centralWidget() != widget) {
    4. d->layout->centralWidget()->hide();
    5. d->layout->centralWidget()->deleteLater();
    6. }
    7. d->layout->setCentralWidget(widget);
    8. }

    so, setCentralWidget always call method deleteLater().

    There is some ways to do it, for example:
    centralWidget()->setParent(NULL);
    //then we can use setCentralWidget()

    1) Is there some other ways to do it?
    2) Hmm.. can I redefenition deleteLater() in centralWidget()?
    Last edited by Usernаme; 19th May 2010 at 13:01.

Similar Threads

  1. Replies: 4
    Last Post: 19th May 2009, 08:06
  2. Rarely crushing application when deleting widget
    By nedlab in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2009, 09:58
  3. Problem with setCentralWidget
    By blm in forum Qt Programming
    Replies: 3
    Last Post: 2nd September 2008, 12:33
  4. Replies: 2
    Last Post: 7th June 2008, 13:12
  5. QMainWindow setCentralWidget from ui widget, Qt4
    By alan in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2008, 13:00

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.