简体   繁体   中英

Qt5 QTreeView editable with virtual keyboard

Working on a touch-screen kiosk system that has a virtual keyboard widget. In all dialogs, the virtual keyboard is the only method of non-touch input. I am now working on a QTreeView for displaying file names using QFileSystemModel, and I have added a column called New Name (all other columns other than Name are hidden). I have overridden createEditor() and destroyEditor() for the delegate I assigned to the QTreeView, and have overridden the data() and setData() for the model. The createEditor() override returns a pointer to a local QLineEdit object so that I can control the results of the edit (plugging them in to my model's data object for that new column).

With my physical keyboard I am able to make changes to the New Name cell for the given row, but I cannot figure out how to type on my virtual keyboard without losing focus and calling destroyEditor() on the item I'm editing. Any ideas as to how this can be done? I've dug into the Qt code, but no luck so far.

The virtual keyboard must not have any focusable widgets. It should be focus-neutral. It won't be stealing the focus, then. This answer has a working example that doesn't steal focus and synthesizes keypress events that get posted to the focused widget.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM