View Full Version : Setting a cursor on QTextEdit
Erlendhg
20th March 2007, 15:41
Hi!
Was just wondering how to set the mouse cursor on the QTextEdit.
setCursor() doesn't work.
viewPort()->setCursor() does work, but when I compile the program to an *.exe, and run it, that line makes it crash.
And I don't want to use QApplication::setOverrideCursor...
Anyone able to help me?
Thanks
high_flyer
20th March 2007, 16:45
setCursor() doesn't work.
Sure it doesn, if you use it right! ;)
Show us your code.
Erlendhg
20th March 2007, 17:20
Quite simple:
The pointing hand cursor won't override the default IBeam (isn't it ?)
#include "myclass.h"
myClass::myClass(QWidget *parent)
: QTextEdit(parent)
{
setMouseTracking(true);
}
myClass::~myClass()
{
}
void myClass::mouseMoveEvent(QMouseEvent *event)
{
setCursor(Qt::PointingHandCursor);
}
jpn
20th March 2007, 17:27
Try
viewport()->setMouseTracking(true);
Erlendhg
20th March 2007, 17:30
But wouldn't that just help if mouseMoveEvent wasn't called?
Because mouseMoveEvent is getting called everytime I move the mouse.
setCursor() just doesn't work for me :(
jpn
20th March 2007, 17:45
How about
viewport()->setCursor(Qt::PointingHandCursor); then? :)
Erlendhg
20th March 2007, 17:53
viewPort()->setCursor() does work, but when I compile the program to an *.exe, and run it, that line makes it crash.
The weird about this is that in my new little test program
#include "myclass.h"
myClass::myClass(QWidget *parent)
: QTextEdit(parent)
{
viewport()->setCursor(Qt::PointingHandCursor);
}
myClass::~myClass()
{
}
that actually does work, but not in my big program.
*scratching my head*
Well, this does work for me anyway:
QWidget *viewPort = viewport();
viewPort->setCursor(Qt::PointingHandCursor);
setViewport(viewPort);
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.