PDA

View Full Version : Prevent window size change when font size changes



quimnuss
3rd September 2015, 15:17
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:


static bool adjustToScreen(QRect& rRect)
{
QDesktopWidget* desktop = QApplication::desktop();
QRect rcDesktop = desktop->frameGeometry();

// if the original rect is not completly inside the desktop rectangle, it must be adjusted
if(!rcDesktop.contains(rRect))
{
rRect.setLeft(qMax(rcDesktop.left(), rRect.left()));
rRect.setTop(qMax(rcDesktop.top(), rRect.top()));
rRect.setRight(qMin(rcDesktop.right(), rRect.right()));
rRect.setBottom(qMin(rcDesktop.bottom(), rRect.bottom()));
return true;
}
return false;
}