Results 1 to 5 of 5

Thread: Qwidget Show abnormal /setGeometry not working

  1. #1
    Join Date
    Apr 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Angry Qwidget Show abnormal /setGeometry not working

    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 ?

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Qwidget Show abnormal /setGeometry not working

    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)
    Last edited by saman_artorious; 28th April 2013 at 14:56.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,243
    Thanks
    303
    Thanked 866 Times in 853 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qwidget Show abnormal /setGeometry not working

    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.

  4. #4
    Join Date
    Apr 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Qwidget Show abnormal /setGeometry not working

    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

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qwidget Show abnormal /setGeometry not working

    If you use layouts then calling setGeometry is a no-op as the layout will override it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to show MS Word int QWidget ?
    By luoyes in forum Qt Programming
    Replies: 8
    Last Post: 3rd December 2013, 05:22
  2. QWidget.show () is slow
    By rdf in forum Qt Programming
    Replies: 6
    Last Post: 7th December 2012, 16:04
  3. QWidget::exec() and QWidget::show()
    By MarkoSan in forum Qt Programming
    Replies: 6
    Last Post: 18th October 2007, 22:39
  4. why cant i call setGeometry
    By freegnu in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 05:59
  5. qlayout and setGeometry
    By mickey in forum Qt Programming
    Replies: 4
    Last Post: 2nd April 2006, 13:56

Tags for this Thread

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.