Questions tagged [qcursor]

The QCursor class provides a mouse cursor with an arbitrary shape.

The QCursor class provides a mouse cursor with an arbitrary shape.

This class is mainly used to create mouse cursors that are associated with particular widgets and to get and set the position of the mouse cursor.

Qt has a number of standard cursor shapes, but you can also make custom cursor shapes based on a QBitmap, a mask and a hotspot.

To associate a cursor with a widget, use QWidget::setCursor(). To associate a cursor with all widgets (normally for a short period of time), use QApplication::setOverrideCursor().

To set a cursor shape use QCursor::setShape() or use the QCursor constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the Qt::CursorShape enum.

If you want to create a cursor with your own bitmap, either use the QCursor constructor which takes a bitmap and a mask or the constructor which takes a pixmap as arguments.

To set or get the position of the mouse cursor use the static methods QCursor::pos() and QCursor::setPos().

Note: It is possible to create a QCursor before QApplication, but it is not useful except as a place-holder for a real QCursor created after QApplication. Attempting to use a QCursor that was created before QApplication will result in a crash.

Reference: http://qt-project.org/doc/qt-4.8/qcursor.html

18 questions
5
votes
1 answer

qt : show mouse position like tooltip

As I write on title, I hope to show mouse position like tooltip. To do that, I think that I have to override QCursor, right? But I don't know the details of QCursor and how to make a new cursorShape. Is there any example like this?
Hyun-geun Kim
  • 919
  • 3
  • 22
  • 37
4
votes
1 answer

Qt: Get a standard cursor pixmap

The QCursor class provides methods get and set a QPixmap or a QBitmap on the cursor. I can create a cursor from one of the standard shapes, e.g. Qt::ArrowCursor. However, if I do so, I cannot get the pixmap/bitmap of the cursor! QCursor…
Felix
  • 6,885
  • 1
  • 29
  • 54
4
votes
3 answers

How to prevent mouseMoveEvent on QCursor::setPos() using Qt?

I am currently developing on an image viewer application. In this application I have a so called "pan-zoom" feature. This means that, when holding a certain mouse button, the user can zoom the image by panning forth and back. It works fine, but as…
bweber
  • 3,772
  • 3
  • 32
  • 57
4
votes
1 answer

Qt QCursor::setPos() does nothing

I've created a minimal class to demonstrate my problem. I'm trying to set the cursor position, but it shows no effect. In my example class I try to center the cursor to the widget. Here is my class: class testWidget : public QWidget { …
david
  • 168
  • 1
  • 11
3
votes
1 answer

Is there a way to create a custom animated / gif QCursor?

I am trying to create a custum animated cursor that replaces the regular cursor for when lengthy processes are taking place similar to here and here, however, I woud like mine to be animated, for example using a gif, just as it is the case with the…
mapf
  • 1,906
  • 1
  • 14
  • 40
3
votes
1 answer

Display a cursor on QTextEdit in QT4.8.5

I am newbie working on QT. Basically I am creating a QTextEdit box in QT and I want the Cursor to display at initial position. My Simple Code is : #include "mainwindow.h" #include #include #include
vk41286
  • 113
  • 1
  • 1
  • 10
2
votes
0 answers

PyQt5 - Changing font color under cursor

I'm trying to change the color (Red) of the font that will be highlighted. The problem I'm facing is, as soon as I highlight the first word, all the following text becomes Red. def cursorPosition(self): logging.debug("Cursor Positiong changed") …
b-ak
  • 141
  • 5
2
votes
1 answer

Change the cursor if you pass to a QGraphicsRectItem Qt c++

I would like to change the cursor if I go over a rectangle like QGraphicsRectItem. I have a class that inherits from QGraphicsView and the rectangles are displayed in a QGraphicScene. I implemented mouse events with eventFilter. The problem is that…
user8632386
2
votes
1 answer

Changing cursor shape for QComboBox items

I want to set cursor shape for QComboBox and his items. With setCursor affecting only LineEdit part of QComboBox, how do I access items view to change cursor shape? QComboBox *combo = new…
Shf
  • 3,463
  • 2
  • 26
  • 42
2
votes
1 answer

Use custom image in QCursor

I have a .bmp image that I would like to use as a cursor for my GUI. The QCursor Documentation suggests that this is possible ("To create a cursor with your own bitmap, either use the QCursor constructor which takes a bitmap and a mask or the…
Sadie LaBounty
  • 379
  • 1
  • 5
  • 23
2
votes
1 answer

How to make QT application use native Windows cursors instead of qt specific?

In my application I want to have native Windows cursors icons instead of loaded/built from qt resources. For example Qt::SplitVCursor/Qt::SplitHCursor which differs from standard Windows.
2
votes
1 answer

Call to QCursor::setPos in QML Javascript

The QCursor class of Qt has as public static method called 'setPos'; I want to use this method in QML Javascript. So the question is quite straight forward: How to call this 'setPos' method from QML Javascript?
jondinham
  • 8,271
  • 17
  • 80
  • 137
1
vote
1 answer

Is it possible to create a custom cursor using PyQt?

I wanted to use a bigger version of the crosshair cursor for my program but it seems like i can't change the specs of the standard cursor shapes (e.g. QtCore.Qt.OpenHandCursor). That said, is it possible for me to create a customized version of a…
xjm
  • 164
  • 2
  • 4
  • 18
1
vote
1 answer

Cannot find QCursor in Qt CMake Project

I'm trying to build an application on Linux with Qt where I can set the Cursor position. The project is managed with CMake. CMakeLists.txt: cmake_minimum_required(VERSION 2.8.4) project(Project) add_definitions(-std=gnu++14 -std=c++14 -Wall…
El_Mewo
  • 99
  • 8
0
votes
2 answers

unable to use Qt.OpenHandCursor attribute to set cursor shape

I have a python project that do the following import from PyQt4 import QtGui, QtCore I would like to change the cursor's shape at certain point, for example, I would create a new QCursor object self.cursor_oh =…
For Comment
  • 1,139
  • 4
  • 13
  • 25
1
2