Results 1 to 2 of 2

Thread: Does QWidget::setAttribute() work with QWidget child classes?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Does QWidget::setAttribute() work with QWidget child classes?

    This is a purely theoretical question, no actual code to display (well, one line). If I create a class that inherits from QWidget, does .setAttribute() still work for it? Most importantly, does it work with WA_DeleteOnClose?

    Qt Code:
    1. //...
    2. (myWidget) potato;
    3. potato.setAttribute(Qt::WA_DeleteOnClose);
    4. //....
    To copy to clipboard, switch view to plain text mode 

    Will WA_DeleteOnClose summon the class' destructor or only QWidget's?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Does QWidget::setAttribute() work with QWidget child classes?

    this is a question you can answer yourself. Simply create a subclass and see if the d-tor is called:
    Qt Code:
    1. class MyWidget : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MyWidget(QWidget* parent = 0) : QWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); }
    7. ~MyWidget() { qDebug() << Q_FUNC_INFO; }
    8. }
    To copy to clipboard, switch view to plain text mode 
    and now see the output and your question answered.

Similar Threads

  1. Create a QWidget as child of a Win32 window
    By BenPa in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 29th March 2011, 15:35
  2. change QWidget from QThread classes
    By radeberger in forum Qt Programming
    Replies: 12
    Last Post: 30th May 2010, 20:45
  3. Replies: 4
    Last Post: 17th April 2010, 03:42
  4. Enable QWidget child while parent disabled
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2008, 11:53
  5. Replies: 10
    Last Post: 17th August 2006, 16:12

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.