Results 1 to 10 of 10

Thread: child window with very small size !!!

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Angry child window with very small size !!!

    Hi,

    I have a midi application that create child windows holding a widget

    The problem is that the child windows is always created with the minimum size!



    When it should be something like:




    I am loading the child with:

    Qt Code:
    1. documentWindow *child = createMdiChild();
    2. countries *cnt = new countries(this,database);
    3. child->setCentralWidget(cnt);
    4. child->show();
    5. child->setWindowTitle("Countries Maintenance");
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. documentWindow *MainWindow::createMdiChild()
    2. {
    3. documentWindow *child = new documentWindow;
    4. mdiArea->addSubWindow(child);
    5. return child;
    6. }
    To copy to clipboard, switch view to plain text mode 

    The centralWidget cnt has the size w=508 h=250. Its size policy is fixed.

    Any idea how to correct this so the size of the child matched the size of the centralWidget?

    Thanks!!!

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    Two questions:
    1. Do you use Layouts in child widgets?
    2. Do you set the size policy of child widgets?
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    Do you use Layouts in child widgets?
    No.

    Do you set the size policy of child widgets?
    Yes. Is fixed.

    I also tried to have a main layout in the child window and insert the child widget to the layout but I get the same problem

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    It's strange.
    Can you post your code/form ?
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    Hi,

    Here are the files:

    The UI window that holds the child widget:

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>documentWindow</class>
    4. <widget class="QMainWindow" name="documentWindow">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>517</width>
    10. <height>300</height>
    11. </rect>
    12. </property>
    13. <property name="sizePolicy">
    14. <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    15. <horstretch>0</horstretch>
    16. <verstretch>0</verstretch>
    17. </sizepolicy>
    18. </property>
    19. <property name="windowTitle">
    20. <string>MainWindow</string>
    21. </property>
    22. <widget class="QWidget" name="centralwidget"/>
    23. <widget class="QStatusBar" name="statusbar"/>
    24. </widget>
    25. <resources/>
    26. <connections/>
    27. </ui>
    To copy to clipboard, switch view to plain text mode 

    Abstract of the child widget. I use layouts for some if its widgets but the child widget itself does not have a layout.

    See image here:



    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>countries</class>
    4. <widget class="QWidget" name="countries">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>588</width>
    10. <height>250</height>
    11. </rect>
    12. </property>
    13. <property name="sizePolicy">
    14. <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
    15. <horstretch>0</horstretch>
    16. <verstretch>0</verstretch>
    17. </sizepolicy>
    18. </property>
    19. <property name="toolTip">
    20. <string/>
    21. </property>
    22. <widget class="QLabel" name="Panel2">
    23. <property name="enabled">
    24. <bool>true</bool>
    25. </property>
    26. <property name="geometry">
    27. <rect>
    28. <x>11</x>
    29. <y>32</y>
    30. <width>567</width>
    31. <height>3</height>
    32. </rect>
    33. </property>
    34. <property name="toolTip">
    35. <string/>
    36. </property>
    37. <property name="layoutDirection">
    38. <enum>Qt::LeftToRight</enum>
    39. </property>
    40. <property name="frameShape">
    41. <enum>QFrame::Panel</enum>
    42. </property>
    43. <property name="frameShadow">
    44. <enum>QFrame::Raised</enum>
    45. </property>
    46. <property name="text">
    47. <string/>
    48. </property>
    49. <property name="alignment">
    50. <set>Qt::AlignCenter</set>
    51. </property>
    52. </widget>
    53. <widget class="QWidget" name="verticalLayoutWidget">
    54. <property name="geometry">
    55. <rect>
    56. <x>16</x>
    57. <y>48</y>
    58. <width>300</width>
    59. <height>180</height>
    60. </rect>
    61. </property>
    62. <layout class="QVBoxLayout" name="verticalLayout">
    63.  
    64. .....
    To copy to clipboard, switch view to plain text mode 

    Thanks.


    Added after 39 minutes:


    Even if I set size max and min to the child item and copying that to the container window. The window starts very small

    Qt Code:
    1. child->setCentralWidget(cnt);
    2. child->show();
    3. child->setGeometry(cnt->geometry());
    4. child->setMaximumSize(cnt->maximumSize());
    5. child->setMinimumSize(cnt->minimumSize());
    To copy to clipboard, switch view to plain text mode 

    But when I try to expand it does it automatic to the min size... However there is a refresh error where the content of the tableview does not show properly.
    Last edited by qlands; 6th July 2011 at 16:00.

  6. #6
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    Have you tried to use layout on the "countries" widget?
    A camel can go 14 days without drink,
    I can't!!!

  7. #7
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    Yes I did and I get the same: The window starts very small but when I move it for example, it changes to the proper size... I not even need to resize it.. just move it

    For that case I set the layout of the widget to vertical and then organized its items.

  8. #8
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    If you don't use Main Layout for a Widget, you should reimplement QWidget::sizeHint() function.
    A camel can go 14 days without drink,
    I can't!!!

  9. #9
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: child window with very small size !!!

    What about:

    Qt Code:
    1. child->showMaximized();
    To copy to clipboard, switch view to plain text mode 
    instead of

    Qt Code:
    1. child->show();
    To copy to clipboard, switch view to plain text mode 

    Note that you should first mess with size and geometry and only then call show()
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  10. The following user says thank you to john_god for this useful post:

    qlands (28th July 2011)

  11. #10
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: child window with very small size !!!

    Yep!..
    I had to show it minimized first then set the status to normal.

    Very wierd!!!

Similar Threads

  1. Very small size
    By Xirdus in forum Newbie
    Replies: 4
    Last Post: 11th August 2010, 08:28
  2. Replies: 4
    Last Post: 20th November 2009, 12:25
  3. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 11:40
  4. Replies: 11
    Last Post: 4th June 2008, 07:22
  5. tool bar icon size looking small???
    By darpan in forum Qt Tools
    Replies: 7
    Last Post: 31st March 2006, 16:38

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.