Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: icons on image

  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

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

    Read documentation for QToolButtonand QPushButton

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

    Default Re: icons on image

    Hi
    Thanks for your reply..

    I thing is different...


    Initially i am showing one image using

    this code
    Qt Code:
    1. ui->mylabel->setPixmap(QPixmap("yuvaraj.png"));
    To copy to clipboard, switch view to plain text mode 
    then when i am moving the curser on image , that 4 icons will be displaying on image that time..

    Here i have used the label to display my image ...But label doesn't have mouse over,click event options.

    How can i do this


    Don't mistake me ,i am a beginner..

    Please suggest me

    Thanks

    Yuvaraj R

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

    set setMouseTracking in true for a label and then process mouseMoveEvent of the label.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    Default Re: icons on image

    That one problem of mine..

    If click the slot options for label ,it is showng only 5 options,,,

    like

    1) link activated
    2) link hy..
    3) destroyed
    4) destroyed(QObject *)
    5)costumcontextmenu required...

    I don't get slots like mouseover, clicked like that...

    That why i am struggling.....

    please suggest me


    Thanks

    Yuvaraj R

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

    yes, there is no such slot like mouseOver, you have to process QMouseEvent.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  17. The following user says thank you to spirit for this useful post:

    yuvaraj.yadav (21st April 2009)

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

    Default Re: icons on image

    hi

    My code for mouse over event
    Qt Code:
    1. bool mouseover()
    2. {
    3. if(QPoint(10,10)
    4. {
    5. return TRUE; QPixmap pixmap("image.png");
    6. QPixmap icon("test.png");
    7.  
    8. QPainter painter(&pixmap);
    9. painter.drawPixmap(QPoint(10, 10), icon);
    10.  
    11. QLabel label;
    12. label.setPixmap(pixmap);
    13. label.show();
    14. }
    15. else
    16. {
    17. return FALSE;
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    But it is not working , i think my problem is in condition....

    I have another doubt...

    if mouse satisfied the position of image ,how do display the icons on image,

    Is it using the push button, tool button. I need that icons should in event...

    please suggest me

    Thanks

    Yuvaraj R

  19. #18
    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 never reach this code
    Qt Code:
    1. ...
    2. QPixmap pixmap("image.png");
    3. QPixmap icon("test.png");
    4.  
    5. QPainter painter(&pixmap);
    6. painter.drawPixmap(QPoint(10, 10), icon);
    7.  
    8. QLabel label;
    9. label.setPixmap(pixmap);
    10. label.show();
    11. ...
    To copy to clipboard, switch view to plain text mode 
    because return true; is located in a wrong place
    try this
    Qt Code:
    1. bool mouseover()
    2. {
    3. if(QPoint(10,10)) {
    4. QPixmap pixmap("image.png");
    5. QPixmap icon("test.png");
    6.  
    7. QPainter painter(&pixmap);
    8. painter.drawPixmap(QPoint(10, 10), icon);
    9.  
    10. QLabel label;
    11. label.setPixmap(pixmap);
    12. label.show();
    13. return TRUE;
    14. }
    15. return FALSE;
    16. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    Default Re: icons on image

    But it is giving error in main program

    My main program code is
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "widget.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. Widget w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 


    the errors is

    E:/Qt Programs/yuvaraj/main.cpp:10: error: expected `}' at end of input


    E:/Qt Programs/yuvaraj/main.cpp:10: error: expected unqualified-id at end of input

  21. #20
    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

    can you attach your project?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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.