PDA

View Full Version : Qwidget Show abnormal /setGeometry not working



j1111011
28th April 2013, 11:17
I build a app use QtCreator /MSVC2010 (Win7 )

my app UI extend QWidget,the geometry is (0,0,860,600)

Where i run it on windows xp sp3(only one system is abnormal,anothers is good) , the app show abnormal,show a big big window.

I'm Rewrite the QWidget::resizeEvent(e){
} function,print the size and oldsize information:


i print :

old size -1,-1, new size > 3766,600

but on my PC,the UI show normal,
print:

old size -1,-1, new size > 860,600

then ,i write these code :


if(oldWin.width() == -1 &&
oldWin.height() == -1){
if(size.width() != 860 || size.height() != 600){
resize(860,600);
setGeometry(0,0,860,600);
}
}

in resizeEvent(e);
and the resize and setGeometry do not work ,the window still show abnormal~

who can tell me ? Why ?

saman_artorious
28th April 2013, 13:42
Don't you think that it never enters the condition ? why would it ever be necessary to check width and height with -1 ?

(insert your code between
tags. and don't mix code with statements)

d_stranz
28th April 2013, 18:32
Maybe you should read the documentation for QWidget::geometry(), especially this part:


Warning: Calling setGeometry() inside resizeEvent() or moveEvent() can lead to infinite recursion.

See the Window Geometry documentation for an overview of geometry issues with windows.

j1111011
2nd May 2013, 03:20
thanks for your reply,

my problem is qwidget show abnormal ,at begin, my widget geometry is 0,0,860,600, but it's display an 0,0,3766,600 window. my layout is HorizontalLayout

wysota
2nd May 2013, 06:26
If you use layouts then calling setGeometry is a no-op as the layout will override it.