I got a new hdd, so i can't continue developing. Would it be possible to get the size if i add a QWidget into the QVBoxLayout and add the label to it? or any other constellation?
I got a new hdd, so i can't continue developing. Would it be possible to get the size if i add a QWidget into the QVBoxLayout and add the label to it? or any other constellation?
Yes, but you have to show that widget or at least wait for it to be polished, before you will get a valid size.
nope, i tried several things to get the size, using widgets, labels etc. every time i want to have the size i get a QSize(100,30) (or the equivalent using geometry()) so i have no chance to resize the images using QImage![]()
I hope this code help you.
Qt Code:
lab->setPixmap(p1); lab->show(); lab->setFixedHeight(p1.height()); lab->setFixedWidth(p1.width());To copy to clipboard, switch view to plain text mode
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
you can also use in spite of above.Qt Code:
lab->setFixedHeight(p1.height()); lab->setFixedWidth(p1.width());To copy to clipboard, switch view to plain text mode
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
thanks
now i understand where i was wrong. your code is much easier than my resize-function. Now the main problem to solve: how to get the maximum size the label can occupy?
I attached two screenshots. The first shows the splash, i changed the window-size to be a bit more than the fixed size of the label. Here, you can see the following structure:
where the label at the end holds the image that you can see. this should always use the maximum size, like your code does. I thought i could get the size by using a QWidget instead of the label and attach the label to the widgets layout (i used QVBoxLayout).Qt Code:
To copy to clipboard, switch view to plain text mode
The next screenshot shows the same problem. The area with a black border is a QLabel, that should also display images, but now with Qt::KeepAspectRatio. The Label should resize when window resizes, but by keeping the proportions of the file (image.size=label.size). Would be quite easy i thought some weeks ago...
Use maximumSize() and setMaximumSize() for this.Qt Code:
how to get the maximum size the label can occupyTo copy to clipboard, switch view to plain text mode
And use this code for your problem;
Qt Code:To copy to clipboard, switch view to plain text mode
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
You can set and use after the maximumSize of a widget using maximumSize() and setMaximumSize().
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
Bookmarks