1

I am beginning with a Qt5 programming. I am working on an image crop application. the Qlabel which is holding the loaded image is of a fixed size. I need the Qlabel to auto resize in accordance with the main window size changes

Default screen

resized screen

timrau
  • 22,578
  • 4
  • 51
  • 64
SAHLA
  • 83
  • 1
  • 7

1 Answers1

0

Try using different QLayouts. The entire purpose of Qlayouts is the take of responsibility of sizing and positioning from you. That's something that Qt dose very well, in comparison to other UI frameworks.

Read this http://doc.qt.io/qt-5/layout.html

mentioned in the comment, here's a solution I did in 20mins. http://www.pilypala.com/sites/default/files/resizing.zip

enter image description here enter image description here enter image description here

dudeking
  • 764
  • 1
  • 9
  • 12
  • I've spent the last five years writing qt code and resizing is hands down the most frustrating part. The layout managers are only well behaved in the most trivial cases and all bets are off once you start resizing windows,or heaven forbid have to programmatically resize widgets. – Nicolas Holthaus Jan 06 '15 at 10:12
  • Here's something I cooked up in 20 mins. Most of the time was spent on reading how to use QPixmap, which I never used it before. It works out of box,without even resorting to code. I just used the UI Designer. http://www.pilypala.com/sites/default/files/resizing.zip – dudeking Jan 06 '15 at 14:21
  • I'm not saying that in this case it was a difficult problem, I just read your comment that Qt resizes well and respectfully disagree that that's true in general. – Nicolas Holthaus Jan 06 '15 at 14:25
  • In my opinion, every operating should start using Qt as their main SDK. – dudeking Jan 06 '15 at 14:25
  • Resizing, positioning and all that crap is hard problem not because it's algorithmically difficult because it is tedious. Have you tried doing app development in browsers? It's 10x worse. Also try WPF and whatever. The point is, it's tedious and requires meticulous details. It requires you to know the underlying rendering engine well. Qt is the one framework that makes this process easier, but to do intricated things, all frameworks will require you to know the underlying details. There is no getting around that. – dudeking Jan 06 '15 at 14:30
  • The link is dead, can you edit your answer to include code please? – Josh Nov 02 '16 at 15:27
  • This answer doesn't answer the question. – Graham Leggett Mar 25 '21 at 14:49