Results 1 to 12 of 12

Thread: Parent-child-problems ;)

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Parent-child-problems ;)

    hi again. I am facing a funny problem (nothing unusual ) I have the following design structure:

    parent: Mod_parent (custom Widget)

    children of Mod_parent: c1, c2, c3 (custom Widgets)

    Mod_parent inherits from QWidget.

    c1,c2,c3 also inherit from QWidget.

    c1,c2,c3 are declared as children of Mod_parent in main.cpp

    Problem is this: The children are to be shown only when their corresponding buttons are clicked in the parent. But however when the application starts, all the children are visible, transparently one above the other!!!

    What do you think could be the problem?

    Thanks

    Nupul

    PS: i could paste the code, but it is well over 700 lines!!! so let me know which part would you actually want...I have used the standard inheritance practice followed in most Qt progs. ie Mod_parent(QWidget *parent):QWidget(parent) and same with the children

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by nupul
    What do you think could be the problem?
    When you show the parent, all of its children are shown too. Either add those children after you show the widget or hide just them.

  3. #3
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: Parent-child-problems ;)

    Quote Originally Posted by jacek
    When you show the parent, all of its children are shown too. Either add those children after you show the widget or hide just them.
    for the first part you mean like this:

    Qt Code:
    1. mod_parent->show();
    2.  
    3. c1=new c1(mod_parent);
    4. c2=new......
    5. .
    6. .
    7. .
    8.  
    9. return app.exec();
    To copy to clipboard, switch view to plain text mode 

    and when and where should i hide them?

    Thanks

    Nupul

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by nupul
    for the first part you mean like this:
    Yes, it should be enough.

    Quote Originally Posted by nupul
    and when and where should i hide them?
    Whenever and wherever you like, just after you invoke the show() method.

  5. #5
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: Parent-child-problems ;)

    well I did as told and now the above problem is no longer there but a new one has cropped !!!

    The children c1,c2,c2 are all coming as transparent ??

    They had the framelesswindowhint flag enabled, even after disabling it, the children are still coming frameless!

    What could be going on??

    Thanks

    Nupul

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by nupul
    The children c1,c2,c2 are all coming as transparent
    What do you mean by "transparent"? Are these c1, c2 and c3 ordinary widgets or windows?

  7. #7
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Arrow Re: Parent-child-problems ;)

    Quote Originally Posted by jacek
    What do you mean by "transparent"? Are these c1, c2 and c3 ordinary widgets or windows?
    Well c1,c2,c3 are all individual windows having the Qt::FramelessWindowHint flag enabled

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by nupul
    Well c1,c2,c3 are all individual windows having the Qt::FramelessWindowHint flag enabled
    Did you set the Qt::Window flag? Without it those widgets won't be separate windows.

  9. #9
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by jacek
    Did you set the Qt::Window flag? Without it those widgets won't be separate windows.
    I commented it out but otherwise I have the Qt::SubWindow flag enabled...but still i fail to understand, howcome the transparency?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by nupul
    but still i fail to understand, howcome the transparency?
    Probably because of Qt::SubWindow, which tells Qt that this widget is not a standalone window. What flags did you set?

  11. #11
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by jacek
    Probably because of Qt::SubWindow, which tells Qt that this widget is not a standalone window. What flags did you set?
    Actuall none...as in after enabling the Qt::Window flag, i see the widgets in their own window. But after commenting out all the flags, I see the label/buttons etc of the children, but on the background of the parent!!

    Nupul

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent-child-problems ;)

    Quote Originally Posted by nupul
    after enabling the Qt::Window flag, i see the widgets in their own window.
    Is that what you want?

    Quote Originally Posted by nupul
    But after commenting out all the flags, I see the label/buttons etc of the children, but on the background of the parent!!
    Because you have told Qt to place that widget on its parent --- just like a button or combo box.

Similar Threads

  1. let parent widget grow with child widget?
    By BeS in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 12:17
  2. connecting child to parent window...
    By sumit in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2008, 22:28
  3. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 12:40
  4. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 13:00
  5. Referencing Parent Widget from Child
    By taylor34 in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2006, 16:13

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.