Qt mouse cursor transparency

I would like to change the cursor with a translucent, simple filled circle, of various sizes, depending on the zoom level of the base widget (say, RGBA = 200, 200, 200, 128).

Is this possible with Qt? If not, is this a limitation in Qt or the underlying libs? Do you have any suggestions on how this can be achieved by other means, for example, hiding the cursor and imposing a transparent pixmap at the cursor position (albeit slower)? TIA

+4
source share
2 answers

QCursor can accept QPixmap, which supports alpha channel. Therefore, I do not understand why this is not possible.

+1
source

I just figured it out for my own project. I did this using this code in the constructor of the corresponding widget:

m_LPixmap = new QPixmap(32,32); m_LPixmap->fill(Qt::transparent); // Otherwise you get a black background :( QPainter painter(m_LPixmap); QColor red(255,0,0,128); painter.setPen(Qt::NoPen); // Otherwise you get an thin black border painter.setBrush(red); painter.drawEllipse(0,0,32,32); m_Cursor = QCursor(*m_LPixmap); setCursor(m_Cursor); 
+1
source

All Articles