Results 1 to 2 of 2

Thread: window size out of control , error is setGeometryDp: Unable to set geometry

  1. #1
    Join Date
    Apr 2016
    Posts
    37
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default window size out of control , error is setGeometryDp: Unable to set geometry

    hi , all.

    my Widget use flowlayout (Qt example) and QWebView.

    but When the window display , size out of control.

    I don't know what happened.

    print "setGeometryDp: Unable to set geometry 727x262+356+299 on QWidgetWindow/'WidgetWindow'. Resulting geometry: 727x662+356+299 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 40x62, maximum size: 16777215x16777215)."

    w_mailview.h
    Qt Code:
    1. #ifndef W_MAILVIEW_H
    2. #define W_MAILVIEW_H
    3.  
    4. #include <QWidget>
    5. #include <QVBoxLayout>
    6. #include <QHBoxLayout>
    7. #include <QWebView>
    8. #include "qflowlayout.h"
    9.  
    10. class W_MailAddress;
    11. class W_MailView_Details;
    12.  
    13. class W_MailView : public QWidget
    14. {
    15. Q_OBJECT
    16. public:
    17. explicit W_MailView(QWidget *parent = 0);
    18. ~W_MailView();
    19. void initUI();
    20. private:
    21. QVBoxLayout * m_vbLayoutMain;
    22. W_MailView_Details * m_wgt_details;
    23. QWebView * m_wv_mail;
    24.  
    25. };
    26.  
    27. class W_MailView_Details : public QWidget{
    28. Q_OBJECT
    29. public:
    30. explicit W_MailView_Details(QWidget * parent = 0);
    31. ~W_MailView_Details();
    32.  
    33. void initUI();
    34. void init();
    35.  
    36. private:
    37. bool m_bInit;
    38. QVBoxLayout * m_vbLayoutDetailsMain;
    39. W_MailAddress * m_wgtAddress_recipient;
    40.  
    41. };
    42.  
    43. class W_MailAddress : public QWidget{
    44. Q_OBJECT
    45. public:
    46. explicit W_MailAddress(QWidget * parent = 0);
    47. ~W_MailAddress();
    48. private:
    49. QFlowLayout * m_flowlayout;
    50. };
    51.  
    52. #endif // W_MAILVIEW_H
    To copy to clipboard, switch view to plain text mode 


    this is w_mailview.cpp
    Qt Code:
    1. #include "w_mailview.h"
    2. W_MailView::W_MailView(QWidget *parent) : QWidget(parent)
    3. {
    4. m_vbLayoutMain = new QVBoxLayout();
    5. this->setLayout(m_vbLayoutMain);
    6. m_vbLayoutMain->setContentsMargins(0,0,0,0);
    7. m_vbLayoutMain->setSpacing(0);
    8. initUI();
    9. }
    10.  
    11. W_MailView::~W_MailView(){
    12.  
    13. }
    14.  
    15. void W_MailView::initUI(){
    16. m_wgt_details = new W_MailView_Details(this);
    17. m_wgt_details->init();
    18. m_wgt_details->setMaximumHeight(40);
    19. m_wgt_details->setMinimumHeight(40);
    20. m_vbLayoutMain->addWidget(m_wgt_details);
    21.  
    22. m_wv_mail = new QWebView(this);//if QWebView replace with QWidget , normal
    23. m_vbLayoutMain->addWidget(m_wv_mail);
    24. }
    25.  
    26. W_MailView_Details::W_MailView_Details(QWidget *parent){
    27. m_bInit = false;
    28. }
    29.  
    30. W_MailView_Details::~W_MailView_Details(){
    31.  
    32. }
    33.  
    34. void W_MailView_Details::init(){
    35. initUI();
    36. }
    37.  
    38. void W_MailView_Details::initUI(){
    39. m_vbLayoutDetailsMain = new QVBoxLayout(this);
    40. m_wgtAddress_recipient = new W_MailAddress(this);
    41. m_vbLayoutDetailsMain->addWidget(m_wgtAddress_recipient);
    42.  
    43. //设置背景ffffff
    44. QPalette pal(this->palette());
    45. pal.setColor(QPalette::Background,QColor("#ffffff"));
    46. this->setAutoFillBackground(true);
    47. this->setPalette(pal);
    48. }
    49.  
    50. ///////////////////////////////////////////
    51. /// \brief The W_MailAddress class
    52. ///
    53. W_MailAddress::W_MailAddress(QWidget *parent)
    54. :QWidget(parent)
    55. {
    56. m_flowlayout = new QFlowLayout;
    57. m_flowlayout->setContentsMargins(0,0,0,0);
    58. m_flowlayout->setSpacing(0);
    59. this->setLayout(m_flowlayout);//if unuse flowlayout , normal
    60. }
    61.  
    62. W_MailAddress::~W_MailAddress(){
    63. if(m_flowlayout)
    64. delete m_flowlayout;
    65. m_flowlayout = NULL;
    66. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2012
    Posts
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: window size out of control , error is setGeometryDp: Unable to set geometry

    Swapping the calls to setMinimumHeight and setMaximumHeight may do the trick: the printed message says that the minimum height is 62. If you then set the maximum height to 40, your maximum height is smaller than your minimum height which is a likely trigger for that kind of assert message.

Similar Threads

  1. Replies: 2
    Last Post: 8th December 2013, 05:53
  2. change text size and window size - qmessagebox
    By smemamian in forum Newbie
    Replies: 3
    Last Post: 4th July 2013, 07:38
  3. Replies: 4
    Last Post: 20th November 2009, 12:25
  4. Storing window geometry inside XML file.
    By GuS in forum Qt Programming
    Replies: 4
    Last Post: 17th July 2008, 13:42
  5. Replies: 2
    Last Post: 23rd April 2006, 01:02

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.