Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making Qt Widgets Stretch and Scale w/ Main Window

I'm wondering if there is a way to make Qt widgets within a QMainWindow widget stretch and scale as the size of the main window is stretched and shrunk. Basically, I'd like the entire window and it's contents to have the same appearance except for size: enter image description here

At the only way I can think to accomplish this is to get the size of the main window, do the math for every single widget, and reset their sizes any time the main window size is changed, but I'm thinking there's an easier way.

like image 277
sj755 Avatar asked Jan 23 '26 02:01

sj755


1 Answers

I like this video tutorial on youtube. I'll help you create a layout using QLayout classes. If you use QtCreator/Designer, you can also take a look at the auto-generated ui_MainWindow.XXX file that will clue you in on how it uses some of the UI classes.

As always, QtCreator/Designer has a bunch of hints and tips so you should be able to dig up from the documentation that's embedded in the application.

like image 75
Huy Avatar answered Jan 25 '26 14:01

Huy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!