Results 1 to 3 of 3

Thread: widget not resized within QDockWidget

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default widget not resized within QDockWidget

    I added a new QDockWidget as all the other ones I already have. However this time the Widget is not resized within the QDockWidget, as if it had not layout.

    It is created with this code:
    Qt Code:
    1. dockAppMessages = new QDockWidget(this);
    2. dockAppMessages->setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea | Qt::LeftDockWidgetArea);
    3. widgetDockErrorMessageImpl = new widgetDockErrorMessage(dockAppMessages);
    4. dockAppMessages->setWidget(widgetDockPhaseShapesImpl);
    5. dockAppMessages->setWindowTitle("Application Messages");
    6. addDockWidget(Qt::BottomDockWidgetArea , dockAppMessages);
    7. menuView->addAction(dockAppMessages->toggleViewAction());
    To copy to clipboard, switch view to plain text mode 

    widgetDockErrorMessage, the widget displayed within QDockWidget has a Layout, set to Expanding.

    The ui file is the following
    Qt Code:
    1. void setupUi(QWidget *widgetDockErrorMessage)
    2. {
    3. if (widgetDockErrorMessage->objectName().isEmpty())
    4. widgetDockErrorMessage->setObjectName(QString::fromUtf8("widgetDockErrorMessage"));
    5. widgetDockErrorMessage->resize(499, 153);
    6. QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    7. sizePolicy.setHorizontalStretch(0);
    8. sizePolicy.setVerticalStretch(0);
    9. sizePolicy.setHeightForWidth(widgetDockErrorMessage->sizePolicy().hasHeightForWidth());
    10. widgetDockErrorMessage->setSizePolicy(sizePolicy);
    11. gridLayout = new QGridLayout(widgetDockErrorMessage);
    12. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    13. ErrorList = new WidgetListStringStack(widgetDockErrorMessage);
    14. ErrorList->setObjectName(QString::fromUtf8("ErrorList"));
    15. sizePolicy.setHeightForWidth(ErrorList->sizePolicy().hasHeightForWidth());
    16. ErrorList->setSizePolicy(sizePolicy);
    17.  
    18. gridLayout->addWidget(ErrorList, 0, 0, 1, 1);
    19.  
    20. horizontalLayout = new QHBoxLayout();
    21. horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
    22. horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    23.  
    24. horizontalLayout->addItem(horizontalSpacer);
    25.  
    26. pushButtonClearList = new QPushButton(widgetDockErrorMessage);
    27. pushButtonClearList->setObjectName(QString::fromUtf8("pushButtonClearList"));
    28.  
    29. horizontalLayout->addWidget(pushButtonClearList);
    30.  
    31.  
    32. gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);
    33.  
    34.  
    35. retranslateUi(widgetDockErrorMessage);
    36.  
    37. QMetaObject::connectSlotsByName(widgetDockErrorMessage);
    38. } // setupUi
    To copy to clipboard, switch view to plain text mode 

    Any ideas?

    Matthias

  2. #2
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: widget not resized within QDockWidget

    Quote Originally Posted by pospiech View Post
    Qt Code:
    1. widgetDockErrorMessageImpl = new widgetDockErrorMessage(dockAppMessages);
    2. dockAppMessages->setWidget(widgetDockPhaseShapesImpl);
    To copy to clipboard, switch view to plain text mode 
    The correct version of the above code is
    Qt Code:
    1. widgetDockErrorMessageImpl = new widgetDockErrorMessage(dockAppMessages);
    2. dockAppMessages->setWidget(widgetDockErrorMessageImpl);
    To copy to clipboard, switch view to plain text mode 

    which makes the problem disappear...

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: widget not resized within QDockWidget

    Using a little bit more distinct variable names would've made the error visible. I still had to stare a few seconds the see what's the actual difference in your solution...
    J-P Nurmi

Similar Threads

  1. Replies: 10
    Last Post: 20th April 2015, 23:24
  2. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 08:06
  3. Playbutton functionality
    By uchennaanyanwu in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2008, 23:29
  4. How to Open & Close a Widget ?!!
    By Fatla in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2008, 21:39
  5. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 11:35

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.