PDA

View Full Version : How to get the path of an image



stbb24
4th June 2012, 16:23
I have a button that let's users browse for images and a line edit that' suppose to display the path of the image when the button is clicked. Unfortunately after choosing the image nothing get's displayed in the line edit. I thought it was automatic that the path will be displayed like Visual Basic.

So how can I get the path (ex: Pictures/2.jpg) of an image and display it in a line edit when the button is clicked?

^NyAw^
4th June 2012, 16:40
Hi,

Get the path that from the dialog an get it to the lineEdit.

stbb24
4th June 2012, 17:00
Can you explain further??

tferreira
4th June 2012, 17:05
If you show some code, we could help you further :)

ChrisW67
5th June 2012, 05:55
I thought it was automatic that the path will be displayed like Visual Basic.
In my experience it's not automatic in VB that a line edit and a separate dialog launched by a separate button are in any way related.

So how can I get the path (ex: Pictures/2.jpg) of an image and display it in a line edit when the button is clicked?
By doing exactly what you wrote:

Get the value returned from the open file dialog, i.e the return value from QFileDialog::getOpenFileName() or QFileDialog::selectedFiles() depending on how you created the dialog in the first place.
Put it in the line edit, i.e. QLineEdit::setText()

stbb24
7th June 2012, 06:44
Thanks got it to work using setText()