Results 1 to 1 of 1

Thread: [SOLVED] QLineEdit Input

  1. #1
    Join Date
    Jul 2008
    Thanked 18 Times in 15 Posts
    Qt products

    Default [SOLVED] QLineEdit Input

    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.

    Qt Code:
    1. void NumPad::numEntry(QGraphicsItem *item)
    2. {
    3. QVariant count = item->data(QVariant::Int);
    4. int result = count.value<int>();
    5. QKeyEvent myevent(QEvent::KeyPress,result,Qt::NoModifier,"UI");
    6. qDebug() << QCoreApplication::sendEvent(widget,&myevent);
    7. qDebug() << widget << &myevent << focusProxy() << focusWidget();
    9. }
    To copy to clipboard, switch view to plain text mode 
    Here is the debug output if it helps.
    QWidget(0x478f18, name = "Form") QKeyEvent(KeyPress, 33, 0, """", false, 1) QWidget(0x478f18, name = "Form") NumPad(0x47eed8, name = "NumPad")

    Solved this issue by adding the unicode value of the string. String is now displayed in the widget.
    Qt Code:
    1. QKeyEvent myevent(QEvent::KeyPress,count.value<int>(),Qt::NoModifier,count.toChar());
    To copy to clipboard, switch view to plain text mode 
    Last edited by QbelcorT; 24th November 2008 at 09:42.

Similar Threads

  1. QLineEdit and input mask
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 9th May 2014, 20:47
  2. QtEmbedded TouchScreen Input Methods
    By QbelcorT in forum Newbie
    Replies: 0
    Last Post: 23rd November 2008, 08:43
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 16:13
  4. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 02:25
  5. QLineEdit check Input
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 17th August 2006, 15:32


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.