Results 1 to 15 of 15

Thread: Wierd behaviour after resizing child dialogue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Wierd behaviour after resizing child dialogue

    O wow. I get it now! Thanks!

  2. #2
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: Wierd behaviour after resizing child dialogue

    Sorry I have to reopen this question:

    I tried the code jpn suggested, the code worked fine, but the problem is still there.

    Also for those widgets, for example, the initialization of them, the formal way is

    Wedgit awedgit=new Wedgit(* parent); or awdgit=Wedgit(*parent);?

    Then this means the parent, has to be a pointer when instantiated? '

    Then that means in the Child class, I will have to declare some pointers to Widget (that is the parents) so that means the memory leak is not preventable?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Wierd behaviour after resizing child dialogue

    You don't have to declare anything.

    Qt Code:
    1. class MyWidget : public QWidget {
    2. public:
    3. MyWidget(QWidget *parent =0 ) : QWidget(parent){
    4. QLabel *lab = new QLabel(this); // current object (this) is set as the parent)
    5. lab->setText("TEST");
    6. }
    7. };
    8.  
    9. int main(int argc, char **argv){
    10. QApplication app(argc, argv);
    11. MyWidget wgt;
    12. wgt.show();
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 
    When "wgt" is destroyed so are all its child QObjects (the label being one of them). No memory leak and no pointers declared (and no dangling pointers).

  4. #4
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Wierd behaviour after resizing child dialogue



    What I meant was actually
    say in your example,
    the MyWedgit, it is a child of another wedgit(for example YourWedigt, then when we initialize a MyWedgit object we have to use a pointer to YourWedgit as the first parameter. (I tried use simply an object instead of a pointer, and the compiler complained, either saying I cannot access the private object, or says cannot convert an object to a pointer).

    The case you were showing me with "this", as the tool tip told me before, "this" was a pointer itself.

    I guess I have created a bit too many classes to call one from another?

    hope I made myself clear... and hope what I just written isn't something stupid...

  5. #5
    Join Date
    Mar 2007
    Posts
    30
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Wierd behaviour after resizing child dialogue

    Actually never mind...the problem isn't that serious any more. As long as I wait until the QT evaluation warning panel disappear, and run my program, it doesn't show up any more.

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.