PDA

View Full Version : [SOLVED] QLineEdit Input



QbelcorT
24th November 2008, 04:37
HI,
I have an embedded proxy widget, with a ui form being displayed. I have QlineEdits widgets within this proxy.
I made another widget (nonproxy). This widget is a number pad. When the number buttons are pressed (touchscreen), I want that event to be sent to the currently focused QlineEdit widget (in my proxy). The numpad only pops up when the proxy widget is touched.
I am trying to simulate a keypressevent in my numpad widget, and then send this event to the proxy widget, however seems like the event is not being accepted by the qlineedit widget, I am expecting the number to be displayed but it isn't.
The event key is Qt::Key_1-Key-9. Basically when the graphicsitem is pressed, it emits a signal to this slot, and the data is variant int.
Numpad has no parent widget. If I parent it with the proxy then the numpad operation isn't working (key responses are slow)

Any ideas on how OR why I cannot forward my key inputs to the proxywidget?

Thank you.



This is my event simulation function, is in a subclassed QGraphicsView.


void NumPad::numEntry(QGraphicsItem *item)
{
QVariant count = item->data(QVariant::Int);
int result = count.value<int>();
QKeyEvent myevent(QEvent::KeyPress,result,Qt::NoModifier,"UI");
qDebug() << QCoreApplication::sendEvent(widget,&myevent);
qDebug() << widget << &myevent << focusProxy() << focusWidget();

}
Here is the debug output if it helps.
true
QWidget(0x478f18, name = "Form") QKeyEvent(KeyPress, 33, 0, """", false, 1) QWidget(0x478f18, name = "Form") NumPad(0x47eed8, name = "NumPad")

EDIT::
Solved this issue by adding the unicode value of the string. String is now displayed in the widget.


QKeyEvent myevent(QEvent::KeyPress,count.value<int>(),Qt::NoModifier,count.toChar());