Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Automatic resizing of window
Qt 6.11 is out! See what's new in the release blog

Automatic resizing of window

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ASVA
    wrote on last edited by
    #1

    Hello everybody. Here is my problem:

    I am developing a Qt app using QTEditor. The app needs to resize itself at runtime, depending on how many graphical elements are attached to it. I thought of handling this through a shrink() method in the main window:

    @class MainWindow : public QMainWindow {
    ...

    private slots:
    void shrink() {
    resize(minimumSizeHint());
    // Also tried: resize(0, 0);
    }
    };@

    Calling shrink() can however be quite hit and miss. Sometimes, the window does get resized to the intended, minimal size. Other times, it keeps its original size, and I need to call shrink() again to get the intended outcome. It is suggested "here":http://developer.qt.nokia.com/forums/viewthread/4597 that this is a timing issue. The proposed solution is to call shrink() throgh QTimer::singleShot, such as:

    @QTimer::singleShot(0, this, SLOT(shrink());@

    However, this has no effect in my case. Even throwing in a call to QtApplication::processEvents() has no effect.

    Are you aware of any other solution ?

    Thank you.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to devnet

      Is the slot shrink() activated by the singleShot?
      Since there might be timing issue, you might want to give a bit more time before firing the shot.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved