Results 1 to 3 of 3

Thread: change cursor

  1. #1
    Join Date
    Jan 2007
    Posts
    2

    Smile change cursor

    Hi all~~ a new guy of Qt. i got a problem about setCursor~~, when pressing mouse button on a label, the cursor cannot be altered by using the function setCursor. Help me!

  2. #2
    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: change cursor

    and why not ?

    Check this code..
    Qt Code:
    1. #include <QApplication>
    2. #include <QLabel>
    3. #include <QMainWindow>
    4.  
    5.  
    6. class CLabel :public QLabel
    7. {
    8. public:
    9. void mousePressEvent ( QMouseEvent * event );
    10. void mouseReleaseEvent ( QMouseEvent * event );
    11. };
    12.  
    13. void CLabel::mousePressEvent(QMouseEvent * event )
    14. {
    15. setCursor(Qt::CrossCursor);
    16. }
    17.  
    18. void CLabel::mouseReleaseEvent(QMouseEvent * event )
    19. {
    20. setCursor(Qt::ArrowCursor);
    21. }
    22.  
    23. int main (int argc, char *argv[])
    24. {
    25. QApplication app(argc,argv);
    26.  
    27. QMainWindow window;
    28. CLabel label;
    29. window.setCentralWidget(&label);
    30.  
    31. window.show();
    32.  
    33. return app.exec();
    34.  
    35. }
    To copy to clipboard, switch view to plain text mode 

    hope this helps

  3. #3
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: change cursor

    nicky,
    is your question:
    when you move the mouse over label then you want to change cursor and when you move away then cursor come to old style?

Similar Threads

  1. How to synchronize text cursor and cursor in QTextEdit
    By kennyxing in forum Qt Programming
    Replies: 6
    Last Post: 18th February 2007, 09:14
  2. QGraphicsTextItem: handling cursor position change
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2007, 10:42
  3. Make the cursor visible in textEdit (Qt3.3.5)
    By vermarajeev in forum Qt Programming
    Replies: 9
    Last Post: 24th January 2007, 22:50
  4. Replies: 7
    Last Post: 8th September 2006, 16:19
  5. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03

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.