View Full Version : display image and get coordinates
ready
21st March 2011, 09:20
Need help
Hi everybody I am newbie to Qt Gui application....before I haved worked with simple programs in dot net platform.....now I want to get started with Qt straight by displaying images and get co-ordinate of image when I click on the image...
I want it to be done urgently...
please help me
wysota
21st March 2011, 10:02
I would suggest you start with something simpler. Like at least following some of the tutorials and examples Qt has.
ready
21st March 2011, 10:49
can you please provide the link for latest Qt GUI application tutorial
wysota
21st March 2011, 10:51
All materials are available in the reference manual, either offline or online.
ready
21st March 2011, 11:13
atleast tell me which ui tool is used for image displaying
Archa4
21st March 2011, 11:23
I think u can use QLabel->setPixmap(...)
ready
21st March 2011, 11:29
As u suggested i used label which is in display widget..
my code:
void MainWindow::on_pushButton_2_clicked()
{
QPixmap *img = new QPixmap("freedom.jpg");//this image is in folder that contains exe
ui->imagelabel->setPixmap(*img);//named the label as imagelabel
ui->imagelabel->show();
}
but this does not show error and neither it displays the image ............please help
Archa4
21st March 2011, 12:01
Well... here is the code i used:
QImage image("C:/Picture.jpg");
imageLabel->setPixmap(QPixmap::fromImage(image));
And I didn't used the ui thing, so I really can't help there...
ready
21st March 2011, 12:23
thank you Archa4.....It really worked....
I would like to ask one more question...is it possible to get the co-ordinates from the picture displayed in label just by clicking with mouse ....ie mouse handling....
I have got no idea how to do it in qt please help
Archa4
21st March 2011, 12:46
Well... I found another thing in documentation:
http://doc.trolltech.com/4.7/qwidget.html#pos-prop
It shows the position of a widget within the parent's widget.
I think u can use it like
QPoint point = imagelabel->pos();
But i cannot be sure...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.