Qt click the input box to pop up the Input Panel and change the window position

Source: Internet
Author: User
Qtqlineedit input box Input Panel keyboard eventfilter change window position it  
1. Define an Event Filter

Bool mydialog: eventfilter (qobject * o, qevent * E ){ If (e-> type () = qevent: mousebuttonpress) & (O = lineedit ))  {    Updataposition (); // display the Input Panel at the bottom of the input box.    Inputpanel. Show ();    Return true;  }  Else returnqdialog: eventfilter (o, e );} 2. Install the Event Filter on the input box, lineedit-> installeventfilter (this); void mydialog: updateposition (){ Qwidget * widget = focuswidget (); // obtain the control of the current focus  If (! Widget)    Return;  Qrectwidgetrect = widget-> rect (); // obtain the control's geometric information, that is, width and height.  Qpointpanelpos = qpoint (widgetrect. Left (), widgetrect. Bottom (); // coordinates of the lower left corner of the space and the upper left corner of the space  Panelpos = widget-> maptoglobal (panelpos); // convert to global, that is, coordinates starting from the upper left corner of the screen  Input. Move (panelpos); // move the upper left corner of the Input Panel to the coordinates.}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.