Reputation: 13
My application window can be resized to zero-size. I do not want to restrict the minimum window size. There are several widgets (QLineEdits, QLabels, QPushButtons) layoutet by a HBoxLayout.
At first, all widgets in the HBoxLayout were resized without respecting their sizeHint when the window was very small. Then I used setFixedSize(sizeHint) on them. Now they do not get shrunk below their sizeHint, but instead they start overlapping when the window is very small.
What I want is what Thunderbird does (screenshots attached): It smoothly hides the widgets by moving them out of the window border. Their size is unchanged.
How can I achieve that with the Qt Layouting system?
my application: normal window
https://i.sstatic.net/WLgLy.png
my application: small window
https://i.sstatic.net/IIhhs.png
Thunderbird: normal window
https://i.sstatic.net/AYJ83.png
Thunderbird: small window
https://i.sstatic.net/ZyQou.png
Upvotes: 1
Views: 445
Reputation: 4022
Done & done
Upvotes: 1
Reputation: 2073
Probably that's not what you want but consider this: Put your all stuff in a widget (named just 'widget' here), do not put this 'widget' into any layout just leave it free and add this event function to your window class:
void MainWindow::resizeEvent(QResizeEvent *event){
ui->widget->move(QPoint(event->size().width()-ui->widget->width()-20,ui->widget->y()));
QMainWindow::resizeEvent(event);
}
it works!
Upvotes: 0