Results 1 to 6 of 6

Thread: QCursor change shape in Qt 5

  1. #1
    Join Date
    Jun 2014
    Posts
    20
    Thanks
    2

    Default QCursor change shape in Qt 5

    Hello all,

    my case is a bit rare but lets assume that in my application there is no standard QWindow or QWidget created, only the application is a QApplication.
    I need to change the cursor shape in the runtime.

    Without QWindow or QWidget i have no clue how can i change the cursor shape in Windows 7.
    How can i do it with the help of Qt?

    (Not with ::SetCursor(HCURSOR))

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QCursor change shape in Qt 5

    Have you tried http://doc.qt.io/qt-5/qguiapplicatio...OverrideCursor ?

    Although without any window, there will be no space where you will see the changed cursor.

    Cheers,
    _

  3. #3
    Join Date
    Jun 2014
    Posts
    20
    Thanks
    2

    Default Re: QCursor change shape in Qt 5

    No... the overridecursor works only when there is QWindow created from the source code in Qt 5.3.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QCursor change shape in Qt 5

    Quote Originally Posted by cic1988 View Post
    No... the overridecursor works only when there is QWindow created from the source code in Qt 5.3.
    I don't see any error or warning when doing it in a minimal test program
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv)
    4. {
    5. QGuiApplication app(argc, argv);
    6.  
    7. QGuiApplication::setOverrideCursor(QCursor(Qt::ForbiddenCursor));
    8. qDebug() << "override cursor is" << QGuiApplication::overrideCursor()->shape() << "forbidden is" << Qt::ForbiddenCursor;
    9. }
    To copy to clipboard, switch view to plain text mode 
    and the output suggest it worked

    Cheers,
    _

  5. #5
    Join Date
    Jun 2014
    Posts
    20
    Thanks
    2

    Default Re: QCursor change shape in Qt 5

    I mean the QCursor has stored the shape of cursor, it is correct.
    But the actual handle how it should look like or movement relies on the platform.

    Have you seen this forbidden cursor on the screen when you run the code above?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QCursor change shape in Qt 5

    As anda_skoa said, there is no place you will see the Qt application cursor unless you have a visible window in your program.

    If you want to manipulate the entire Windows mouse pointer theme, or do something to the mouse pointer system-wide then you have to resort to the Windows API.

Similar Threads

  1. Can I change the shape of the form in QML?
    By chong_kimkeang in forum Newbie
    Replies: 1
    Last Post: 7th November 2012, 18:51
  2. Overloading Shape Paint change on scene zoom
    By matteo.boscolo in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2010, 08:15
  3. how to change shape of Qwidget??
    By anupamgee in forum Qt Programming
    Replies: 4
    Last Post: 29th June 2009, 10:54
  4. Change the shape of a frame.
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 07:40
  5. How to change shape fast
    By nileshsince1980 in forum Qt Programming
    Replies: 9
    Last Post: 18th October 2007, 06:49

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.