Results 1 to 20 of 24

Thread: icons on image

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default icons on image

    Hi

    How do display icons on image, when i am moving curser on image..


    please suggest me to set icons on image



    Thanks

    Yuvaraj R

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: icons on image

    have a look at QPainter::drawImage or QPainter::drawPixmap.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: icons on image

    Hi

    Just had gone through that one...



    can anybody post the sample code here


    Thanks

    Yuvaraj R

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: icons on image

    you should write something like this
    Qt Code:
    1. ...
    2. QPixmap pixmap(100, 100);
    3. QPixmap icon("incon.png");
    4.  
    5. QRectF target(10.0, 20.0, 80.0, 60.0);
    6. QRectF source(0.0, 0.0, 70.0, 40.0);
    7.  
    8. QPainter painter(&pixmap);
    9. painter.drawPixmap(target, icon, source);
    10. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: icons on image

    Don't mistake me


    How do i run this code



    Thanks
    yuvaraj

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: icons on image

    like this
    Qt Code:
    1. #include <QtGui>
    2. #include <QApplication>
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QPixmap pixmap("image.png");
    9. QPixmap icon("test.png");
    10.  
    11. QPainter painter(&pixmap);
    12. painter.drawPixmap(QPoint(10, 10), icon);
    13.  
    14. QLabel label;
    15. label.setPixmap(pixmap);
    16. label.show();
    17.  
    18. return app.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: icons on image

    Hi

    Thanks spirit


    How can i set the icons ,it si visible only when curser is moving on image


    Please suggest me


    Thanks

    Yuvaraj

    R

  8. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: icons on image

    use code above in mouseMove or keyPressEvent.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  9. #9
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: icons on image

    thanks for your reply


    can i set actions for label to display that

  10. #10
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: icons on image

    Dont mistake me, but do you use Qt Assistant ? or see Qt Demos ?

    As for your problem, you could use a QToolButtonor QPushButton, and set the icon when mouse is over it. You will need to subclass them, and as spirit said, override the mouse events.

    If you are using label, you could make button as a child of label, and show/hide when the user hovers over a given area. For this too, you will need to subclass QLabel

  11. #11
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: icons on image

    Hi

    I can we display the image using push button and tool button

Similar Threads

  1. Image Commander v.1.2
    By piotrek in forum Qt-based Software
    Replies: 0
    Last Post: 20th April 2009, 10:59
  2. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  3. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  4. Help needed handling image data
    By toratora in forum General Programming
    Replies: 2
    Last Post: 11th May 2007, 09:24
  5. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39

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
  •  
Qt is a trademark of The Qt Company.