PDA

View Full Version : window size out of control , error is setGeometryDp: Unable to set geometry



tiaoweiliao
16th May 2017, 10:13
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

#ifndef W_MAILVIEW_H
#define W_MAILVIEW_H

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QWebView>
#include "qflowlayout.h"

class W_MailAddress;
class W_MailView_Details;

class W_MailView : public QWidget
{
Q_OBJECT
public:
explicit W_MailView(QWidget *parent = 0);
~W_MailView();
void initUI();
private:
QVBoxLayout * m_vbLayoutMain;
W_MailView_Details * m_wgt_details;
QWebView * m_wv_mail;

};

class W_MailView_Details : public QWidget{
Q_OBJECT
public:
explicit W_MailView_Details(QWidget * parent = 0);
~W_MailView_Details();

void initUI();
void init();

private:
bool m_bInit;
QVBoxLayout * m_vbLayoutDetailsMain;
W_MailAddress * m_wgtAddress_recipient;

};

class W_MailAddress : public QWidget{
Q_OBJECT
public:
explicit W_MailAddress(QWidget * parent = 0);
~W_MailAddress();
private:
QFlowLayout * m_flowlayout;
};

#endif // W_MAILVIEW_H


this is w_mailview.cpp

#include "w_mailview.h"
W_MailView::W_MailView(QWidget *parent) : QWidget(parent)
{
m_vbLayoutMain = new QVBoxLayout();
this->setLayout(m_vbLayoutMain);
m_vbLayoutMain->setContentsMargins(0,0,0,0);
m_vbLayoutMain->setSpacing(0);
initUI();
}

W_MailView::~W_MailView(){

}

void W_MailView::initUI(){
m_wgt_details = new W_MailView_Details(this);
m_wgt_details->init();
m_wgt_details->setMaximumHeight(40);
m_wgt_details->setMinimumHeight(40);
m_vbLayoutMain->addWidget(m_wgt_details);

m_wv_mail = new QWebView(this);//if QWebView replace with QWidget , normal
m_vbLayoutMain->addWidget(m_wv_mail);
}

W_MailView_Details::W_MailView_Details(QWidget *parent){
m_bInit = false;
}

W_MailView_Details::~W_MailView_Details(){

}

void W_MailView_Details::init(){
initUI();
}

void W_MailView_Details::initUI(){
m_vbLayoutDetailsMain = new QVBoxLayout(this);
m_wgtAddress_recipient = new W_MailAddress(this);
m_vbLayoutDetailsMain->addWidget(m_wgtAddress_recipient);

//设置背景ffffff
QPalette pal(this->palette());
pal.setColor(QPalette::Background,QColor("#ffffff"));
this->setAutoFillBackground(true);
this->setPalette(pal);
}

///////////////////////////////////////////
/// \brief The W_MailAddress class
///
W_MailAddress::W_MailAddress(QWidget *parent)
:QWidget(parent)
{
m_flowlayout = new QFlowLayout;
m_flowlayout->setContentsMargins(0,0,0,0);
m_flowlayout->setSpacing(0);
this->setLayout(m_flowlayout);//if unuse flowlayout , normal
}

W_MailAddress::~W_MailAddress(){
if(m_flowlayout)
delete m_flowlayout;
m_flowlayout = NULL;
}

gvanvoor
5th July 2017, 13:05
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.