I have set a dial that changes the overall font size. When I set the dial very big, the window resizes, surpassing the screen limits. Also, if I then move the size back to what it was, the window size stays at its maximum size, with contents outside the screen.

How can I prevent the window size from changing OR how can I make it shrink when I move the dial back to its original position?

Would forcing the window to fit at each resize event work? Calling a function like this:

Qt Code:
  1. static bool adjustToScreen(QRect& rRect)
  2. {
  3. QDesktopWidget* desktop = QApplication::desktop();
  4. QRect rcDesktop = desktop->frameGeometry();
  5.  
  6. // if the original rect is not completly inside the desktop rectangle, it must be adjusted
  7. if(!rcDesktop.contains(rRect))
  8. {
  9. rRect.setLeft(qMax(rcDesktop.left(), rRect.left()));
  10. rRect.setTop(qMax(rcDesktop.top(), rRect.top()));
  11. rRect.setRight(qMin(rcDesktop.right(), rRect.right()));
  12. rRect.setBottom(qMin(rcDesktop.bottom(), rRect.bottom()));
  13. return true;
  14. }
  15. return false;
  16. }
To copy to clipboard, switch view to plain text mode