Results 1 to 8 of 8

Thread: Changing cursor shape

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Location
    Poland
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question Changing cursor shape

    I have a problem with cursor (Windows XP SP3, Qt 4.7.0 Creator, both debug and release variants):

    I don't understand behavior of cursor in this program! When i'm clicking on window (not QLabel area) cursor changes its shape as I expected. When I press mouse button cursor changes to "ClosedHandCursor" and when I released one cursor changes to "OpenHandCursor". But if I moved cursor over QLabel area cursor changes its shape ONLY on QLabel area despite the fact that events "mousePressEvent" and "mouseReleaseEvent" are served - see window title.

    Do somebody knows how solve this problem? Thank you.

    ----------------------------------------------------------
    main.cpp
    ----------------------------------------------------------
    Qt Code:
    1. #include <QApplication>
    2. #include "Problem.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. Problem win;
    8. win.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    ----------------------------------------------------------
    problem.h
    ----------------------------------------------------------
    Qt Code:
    1. #include <QWidget>
    2.  
    3. class Problem : public QWidget
    4. {
    5. public:
    6. Problem();
    7. protected:
    8. void mousePressEvent(QMouseEvent *event);
    9. void mouseReleaseEvent(QMouseEvent *event);
    10. };
    To copy to clipboard, switch view to plain text mode 

    ----------------------------------------------------------
    problem.cpp
    ----------------------------------------------------------
    Qt Code:
    1. #include <QtGui>
    2. #include "Problem.h"
    3.  
    4. Problem::Problem()
    5. {
    6. setWindowTitle(" ? ");
    7. setGeometry(50,50,500,300);
    8. setCursor(Qt::OpenHandCursor);
    9.  
    10. QLabel *Label = new QLabel("Label area", this);
    11. Label->setFrameStyle(1);
    12. Label->setGeometry(100,100,200,20);
    13. }
    14. void Problem::mousePressEvent(QMouseEvent *event)
    15. {
    16. setCursor(Qt::ClosedHandCursor);
    17. setWindowTitle(" ClosedHandCursor "));
    18. }
    19. void Problem::mouseReleaseEvent(QMouseEvent *event)
    20. {
    21. setCursor(Qt::OpenHandCursor);
    22. setWindowTitle(" OpenHandCursor "));
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 18th November 2011 at 09:19. Reason: missing [code] tags

Similar Threads

  1. Replies: 0
    Last Post: 18th January 2011, 16:59
  2. QDockWidget splitter, cursor shape
    By alecs1 in forum Qt Programming
    Replies: 4
    Last Post: 12th December 2007, 18:44
  3. Shape changing under other tab using slider/spinbox
    By kramed in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 19:59
  4. Cursor not changing
    By bpetty in forum Newbie
    Replies: 4
    Last Post: 17th July 2007, 15:13
  5. Shape-changing dialog with qt4.1
    By moe in forum Qt Tools
    Replies: 3
    Last Post: 2nd February 2006, 10:12

Tags for this Thread

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.