How to add a functional "upload picture" button?
-
@Pl45m4 Thanks for the tips. I also laid out the first page horizontally (before I had it vertically):
As for the second page, I have it laid out horizontally, and I want the button to change back to be under the image:
@Rangerguy128 said in How to add a functional "upload picture" button?:
and I want the button to change back to be under the image
Wasn't the idea that after clicking the button you load the image in another page in the stacked widget and then show that page?
-
@Pl45m4 Thanks for the tips. I also laid out the first page horizontally (before I had it vertically):
As for the second page, I have it laid out horizontally, and I want the button to change back to be under the image:
@Rangerguy128 said in How to add a functional "upload picture" button?:
As for the second page, I have it laid out horizontally, and I want the button to change back to be under the image:
stacking stuff on top of each other using layouts is not really a thing. At least not in designer. You can get around it in code and using Gridlayout. Then you can assign multiple widgets to a cell to stack them. But thats a workaround I would not necessarily recommend.
-
@Pl45m4 Thanks for the tips. I also laid out the first page horizontally (before I had it vertically):
As for the second page, I have it laid out horizontally, and I want the button to change back to be under the image:
@Rangerguy128
It's up to you, but I don't really understand what you are trying to achieve or why. As I wrote originallyJust create a QLabel (simplest widget which can show an image) and a QPushButton or QToolButton. Lay them out as you please.
If you replace (e.g. with a
QStackedWidget
) the "Upload Image" button/link by the image then the user does not have a chance to pick a different image once they have picked one. Assuming you intend them to be able to replace whenever they wish, why don't you just make a widget with space for the image and the button below it (or wherever)? -
@J-Hilk @jsulm @JonB
If I understand @Rangerguy128 last post right, this was just a notice that he exchanged horizontal and vertical layout from my recommendation. I don't know if there's an issue or question left?
Does it look like you expect now @Rangerguy128 ? -
@Rangerguy128 said in How to add a functional "upload picture" button?:
and I want the button to change back to be under the image
Wasn't the idea that after clicking the button you load the image in another page in the stacked widget and then show that page?
@jsulm My idea is that once the user uploads an image, the page will change to the one with the image and a button below that allows the user to go back. Meanwhile, the button to upload the image will be in the center of the stackedwidget in the first page. Is that probable or maybe somewhat messy or unnecesary?
-
@J-Hilk @jsulm @JonB
If I understand @Rangerguy128 last post right, this was just a notice that he exchanged horizontal and vertical layout from my recommendation. I don't know if there's an issue or question left?
Does it look like you expect now @Rangerguy128 ?@Pl45m4 For the first page, it worked fine enough. For the second one, which is what you used as an example, I tried using horizontal spacers between the image label but it seems that there's an issue:
Anyway to fix this? Is it due to the image label's size? As a reminder, I have it laid out vertically here. -
@Pl45m4 For the first page, it worked fine enough. For the second one, which is what you used as an example, I tried using horizontal spacers between the image label but it seems that there's an issue:
Anyway to fix this? Is it due to the image label's size? As a reminder, I have it laid out vertically here.You need to use vertical spacers then. To push up/down instead of left/right.
Makes sense? :Dedit:
Or check if it still looks ok for you when removing them completely. So you just have the vertical layout with the image abovr the button left. -
You need to use vertical spacers then. To push up/down instead of left/right.
Makes sense? :Dedit:
Or check if it still looks ok for you when removing them completely. So you just have the vertical layout with the image abovr the button left.@Pl45m4 Like this?
Is the image positioned well enough? Should the text be centered or is it not necessary? The uploaded image should be the only thing to be shown in the label.
-
@Pl45m4 Like this?
Is the image positioned well enough? Should the text be centered or is it not necessary? The uploaded image should be the only thing to be shown in the label.
@Rangerguy128 said in How to add a functional "upload picture" button?:
Should the text be centered or is it not necessary? The uploaded image should be the only thing to be shown in the label.
Just try it. You will see that you don't need the text anyway. As soon as you set the image with something like
ui->label->setPixmap(....);
the text will be replaced with the image.
If you make sure that the page with the label is never shown when there is no image, then you don't need any text.
In this case the text is just for you to see where the label actually is. Because when you remove the text, the label is very hard to track in QtDesigner since it's almost invisible. You can only see its border/frame.