Results 1 to 10 of 10

Thread: display image and get coordinates

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display image and get coordinates

    I think u can use QLabel->setPixmap(...)

  2. The following user says thank you to Archa4 for this useful post:

    ready (21st March 2011)

  3. #2
    Join Date
    Mar 2011
    Posts
    36
    Thanks
    30
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display image and get coordinates

    As u suggested i used label which is in display widget..
    my code:
    Qt Code:
    1. void MainWindow::on_pushButton_2_clicked()
    2. {
    3. QPixmap *img = new QPixmap("freedom.jpg");//this image is in folder that contains exe
    4. ui->imagelabel->setPixmap(*img);//named the label as imagelabel
    5. ui->imagelabel->show();
    6.  
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 
    but this does not show error and neither it displays the image ............please help

  4. #3
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display image and get coordinates

    Well... here is the code i used:

    Qt Code:
    1. QImage image("C:/Picture.jpg");
    2. imageLabel->setPixmap(QPixmap::fromImage(image));
    To copy to clipboard, switch view to plain text mode 

    And I didn't used the ui thing, so I really can't help there...

  5. The following user says thank you to Archa4 for this useful post:

    ready (21st March 2011)

  6. #4
    Join Date
    Mar 2011
    Posts
    36
    Thanks
    30
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display image and get coordinates

    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

  7. #5
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display image and get coordinates

    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...

Similar Threads

  1. Qt Image Display...
    By mahe2310 in forum Qt Programming
    Replies: 9
    Last Post: 22nd July 2013, 09:06
  2. Replies: 4
    Last Post: 18th March 2010, 10:11
  3. How to Display the image in Qt
    By sdastagirmca in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2009, 06:17
  4. Image display
    By bmn in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 13:52
  5. Display image
    By Pesho in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 00:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.