QGraphicsTextItem bug on mouse interaction?
I found a fairly big bug with QGraphicsTextItem. Maybe someone can reproduce before I submit a bug report? Also where do I report bugs again?
Code:
#include <QApplication>
#include <QGraphicsRectItem>
#include <QGraphicsTextItem>
#include <QGraphicsScene>
#include <QGraphicsView>
int main(int argc, char *argv[])
{
rect->acceptHoverEvents();
text->setTextInteractionFlags( Qt::TextEditorInteraction );
view.setScene( &scene );
view.show();
return a.exec();
}
Run, select some text, now click on the dotted border of the edit text item.
Mouse interaction stops working.
I tried subclassing it and tried a few things with onmousepress events and such but wasn't able to fix this sucker.
Can someone else confirm this? And possibly a workaround!?!
Re: QGraphicsTextItem bug on mouse interaction?
Quote:
Originally Posted by
mooreaa
I found a fairly big bug with QGraphicsTextItem. Maybe someone can reproduce before I submit a bug report? Also where do I report bugs again?
Mouse interaction stops working.
I tried subclassing it and tried a few things with onmousepress events and such but wasn't able to fix this sucker.
Can someone else confirm this? And possibly a workaround!?!
this is not a bug if focus is lost the cursor not repaint....
if you like permanent edit and cursor blink test this...
Code:
#include <QApplication>
#include <QGraphicsRectItem>
#include <QGraphicsTextItem>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QAbstractTextDocumentLayout>
#include <QBasicTimer>
{
Q_OBJECT
public:
TextDia
::TextDia( const QString txt ,
cursorTime
(false),BackHightlight
(QColor("#a6ffc7")) { setBlinkingCursorEnabled(true);
BackHightlight.setAlpha(80);
}
{
return document()->documentLayout()->frameBoundingRect(document()->rootFrame());
}
void setBlinkingCursorEnabled(bool enable)
{
cursorTime = false; /* leave cursor not paint */
cursorTimeLine.
start( QApplication::cursorFlashTime() / 2,
this);
setTextInteractionFlags ( Qt::TextEditorInteraction );
} else {
cursorTimeLine.stop();
setTextInteractionFlags ( Qt::NoTextInteraction );
}
}
{
if (event->timerId() == cursorTimeLine.timerId()) {
if (!cursorTime) {
cursorTime = true;
} else {
cursorTime = false;
}
update();
}
}
{
Q_UNUSED(widget);
const int text_cursor_position = textCursor().position();
painter->save();
CTX.selections;
painter->setClipRect(boundingRect(), Qt::IntersectClip);
if (cursorTime) {
CTX.cursorPosition = text_cursor_position;
} else {
CTX.cursorPosition = -1;
}
painter->setPen(Qt::NoPen);
CTX.clip = boundingRect();
painter->setBrush(BackHightlight);
painter->drawRect(boundingRect());
document()->documentLayout()->draw(painter,CTX);
painter->setPen(Qt::NoPen);
painter->restore();
}
bool cursorTime;
};
#include "main.moc"
int main(int argc, char *argv[])
{
rect->acceptHoverEvents();
TextDia* text = new TextDia("ABCDEFGHIJKLMNOP",rect,&scene);
view.setScene( &scene );
view.show();
return a.exec();
}
Re: QGraphicsTextItem bug on mouse interaction?
No its not that i lose focus, its that even when I refocus, my mouse interaction does not work at all.
Re: QGraphicsTextItem bug on mouse interaction?
Quote:
Originally Posted by
mooreaa
No its not that i lose focus, its that even when I refocus, my mouse interaction does not work at all.
if I refocus my mouse continue to edit and blink... on your code
Install qt4.4.0 .....
show /Qt/4.4.0_src/examples/graphicsview/diagramscene having a swap to move && edittext
Code:
void DiagramTextItem
::focusOutEvent(QFocusEvent *event
) {
setTextInteractionFlags(Qt::NoTextInteraction);
emit lostFocus(this);
}
//! [2]
//! [5]
{
if (textInteractionFlags() == Qt::NoTextInteraction)
setTextInteractionFlags(Qt::TextEditorInteraction);
}
IMO my work:
http://www.qt-apps.org/content/show....?content=80234