Results 1 to 7 of 7

Thread: Resize Widget To Desktop Size

  1. #1
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Resize Widget To Desktop Size

    Hi,
    I've a question for you...Is there a simple way to resize my widget to desktop size?
    I try this code but it seem don't work fine:
    Qt Code:
    1. int width = QApplication:desktop()->width();
    2. int height = QApplication:desktop()->height();
    3. mainWindow->resize(width, height);
    To copy to clipboard, switch view to plain text mode 
    Infact if I try to get the window height:
    Qt Code:
    1. int mwHeight = mainWindow->height();
    To copy to clipboard, switch view to plain text mode 
    then mwHeight is less of QApplication:desktop()->height() (about 20 pixel)

    Any idea?

    And how I can call directly the maximixe button of the title bar to do the same resize by code?
    Last edited by jpn; 23rd September 2008 at 11:16. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Resize Widget To Desktop Size


  3. #3
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Resize Widget To Desktop Size

    Ok I've solved the problem using the showMaximized method.
    It work fine only if insert before a resize:
    Qt Code:
    1. mainWindow->resize(100,100);
    2. mainWindow->showMaximized();
    To copy to clipboard, switch view to plain text mode 
    Why?
    Last edited by jpn; 23rd September 2008 at 15:10. Reason: missing [code] tags

  4. #4
    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: Resize Widget To Desktop Size

    For me it works with Qt 4 without any additional tricks:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QWidget window;
    7. window.showMaximized();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Resize Widget To Desktop Size

    Quote Originally Posted by jpn View Post
    For me it works with Qt 4 without any additional tricks:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QWidget window;
    7. window.showMaximized();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 
    I know...I try some examples like your code and they works fine.
    However I'm working with Qt3.3.5 and window is a QMainWindow not a QWidget.
    I want remove the resize because I've some problmes with it...so any idea how to resolve the question?

  6. #6
    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: Resize Widget To Desktop Size

    Quote Originally Posted by fruzzo View Post
    I know...I try some examples like your code and they works fine.
    In that case it is highly probable that the bug is on your side. It's just hidden somewhere in a big and complex project. That's why it's always a good idea to put up together a minimal compilable test application reproducing the problem.

    However I'm working with Qt3.3.5 and window is a QMainWindow not a QWidget.
    Actually, QMainWindow IS A QWidget. And QWidget::showFullScreen() functionality is implemented in QWidget code. I doubt you can reproduce the problem with a plain QMainWindow either. If you can reproduce it with a QMainWindow subclass, then the problem might be in that subclass.
    J-P Nurmi

  7. #7
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Resize Widget To Desktop Size

    How can I catch the signal emitted when launch mw->showMaximized()? And a way to know when resize (after showMaximized()) is completed?

Similar Threads

  1. Replies: 5
    Last Post: 25th May 2008, 08:22
  2. Move and resize with layout
    By waediowa in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2008, 08:16
  3. Auto resize Widget to maximum avail. space
    By pospiech in forum Qt Programming
    Replies: 16
    Last Post: 15th April 2008, 14:47
  4. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 13:12
  5. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00

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.