PDA

View Full Version : Mouse button repeat not working on QTextEdit inside QGraphicsScene



Lendrick
17th December 2009, 22:26
Greets!

I'm having some minor difficulty getting a QTextEdit widget to work completely from inside a QGraphicsScene. In general it works okay, but there are two issues:
* The scroll bar doesn't respond to the mouse button being held down. It only works once per mouse click.
* Holding down the mouse button and selecting text doesn't cause it to scroll if you move above or below the QTextEdit.

Here are the mouse event handler functions for my QGraphicsScene:


void MapScene::mousePressEvent(QGraphicsSceneMouseEvent * e) {
QGraphicsScene::mousePressEvent(e);
if(e->isAccepted()) return;

if(mapBox->map && e->button() == Qt::LeftButton) {
mapBox->SetTile(e);
} else if(mapBox->map && e->button() == Qt::MidButton) {
mapBox->mouse_start_x = e->scenePos().x();
mapBox->mouse_start_y = e->scenePos().y();
} else if(mapBox->map && play && player && e->button() == Qt::RightButton) {
player->clearQueue();
player->queueMoveTo(e->scenePos().x() + mapBox->xo, e->scenePos().y() + mapBox->yo, 500);
}
}

void MapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
QGraphicsScene::mouseMoveEvent(e);
if(e->isAccepted()) return;

if(mapBox->map && (e->buttons() & Qt::LeftButton) &&
e->scenePos().x() > 0 && e->scenePos().y() > 0 &&
e->scenePos().x() < this->width() && e->scenePos().y() < this->height()) {
mapBox->SetTile(e);
} else if(mapBox->map && (e->buttons() & Qt::MidButton)) {
emit mapBox->SetXScroll(mapBox->xo - e->scenePos().x() + mapBox->mouse_start_x);
emit mapBox->SetYScroll(mapBox->yo - e->scenePos().y() + mapBox->mouse_start_y);
mapBox->mouse_start_x = e->scenePos().x();
mapBox->mouse_start_y = e->scenePos().y();
}
}

void MapScene::mouseReleaseEvent(QGraphicsSceneMouseEve nt * e) {
QGraphicsScene::mouseReleaseEvent(e);
if(e->isAccepted()) return;
}

Any thoughts?

Thanks!

Bart

Lendrick
18th December 2009, 21:57
bump......