When the keyboard opens, the default layer is shown with letters
How to do that by default shown a layer with numbers?
Qt virtual keyboard follows inputMethodHints. So, you can e.g. create a form with TextField QML types and set different inputMethodHints for different fields like name, phone number, pin code etc. When you change the field keyboard changes its mode. You can set Qt.ImhDigitsOnly restrictive mode for pin code field to only accept numbers turning keyboard to a keypad.
If your keyboard opens with a number layout in a specific text input field it sounds like Qt.ImhPreferNumbers or something like that is set to inputMethodHints. You could try to figure out who sets the value and test to reset by setting it explicitly to Qt.ImhNone.
Related
Now, I have a widget that used for conguring some parameters, There were some QlineEdit with default value and a save button on this widget. People may change the content of QlineEdit. And click the save button, so that the modified parameters can take effect. Here is my question:
How do retrieve changes in the content of all text line edit in this QWidget?
Once I know which edit content has changed, I can judge whether the modified values is legal, and then let the change take effect.
Can anyone give me some ideas?
OS: Windows10
QT: qt 5.9.0
For this situation, It's better to do one more step before manually validating the user's input. The step is to limit the user to enter invalid settings. If your setting value is a number, use QSpinBox or QDoubleSpinBox for floating-point values. If you want to let the user select from multiple predefined values, like gender(Male, Female), use QComboBox or QRadioButton and so forth. Here is the list of Qt's widgets. So bear in mind, using QLineEdit for all of the inputs is not a good idea.
If your input is something more complex, you can use validators. For getting the idea see this question.
At last, you connect the save button's clicked signal to the slot defined in your widget class using Qt's signals and slots mechanism and get values from all of your inputs and check them, and if everything is OK, apply them to your system.
I have to work with a code with custom touch numpad/keyboard implementation. The input field is based on TextInput object and I can achieve the 'static' cursor by modifying its direct members
textInput.cursorVisiblity=true
textInput.cursorPosition=val
It works fine, but the cursor is not blinking.
After some research I find out the solution by calling the method:
inputVal.forceActiveFocus()
It gives me proper blinking cursor, but also provides default keyboard panel which overrides the custom one.
I'd like to somehow turn on only this blinking cursor or at least somehow block the additional keyboard panel
It turned out that there were defined some global virtual keyboard that I had to disable
I would like to implement Custom Entry (Xamarin.forms) when the user focus the Entry, device will show Emoji keyboard.
Short answer
Unfortunately it is impossible without creating your own keyboard, due to Android and iOS platform limitations.
Long answer
Default behaviour on iOS is to show the emoji keyboard icon in the bottom of the keyboard. So it is only one tap away from the user:
Default behaviour on Android is seems to be slightly different and the emoji keyboard is hidden by default:
Luckily, it is very easy to place the emoji keyboard icon by setting the InputType to Android.Text.InputTypes.TextVariationShortMessage | Android.Text.InputTypes.ClassText:
If you are still looking to show the emoji keyboard by default, I am afraid you will have to implement your own keyboard view. Depend on your needs you could add few emojis as buttons and etc.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/entry#customizing-the-keyboard
Customizing the Keyboard
The keyboard that's presented when users interact with an Entry can be set programmatically via the Keyboard property, to one of the following properties from the Keyboard class:
Chat – used for texting and places where emoji are useful.
Default – the default keyboard.
Email – used when entering email addresses.
Numeric – used when entering numbers.
Plain – used when entering text, without any KeyboardFlags specified.
Telephone – used when entering telephone numbers.
Text – used when entering text.
Url – used for entering file paths & web addresses.
This can be accomplished in XAML as follows:
<Entry Keyboard="Chat" />
The equivalent C# code is:
var entry = new Entry { Keyboard = Keyboard.Chat };
I want to implement my own sequence for changing the focus of the active child widget using the Tab key. How to capture the Tab Key press event? I am using Qt5.2
If you want to change focus with Tab , you don't need to do those works, Qt has it as a feature.
First: set the desired widgets to be Qt::TabFocus or Qt::StrongFocus by QWidget::setFocusPolicy( Qt::FocusPolicy policy )
For example, if you want to rotate between 3 QLineEdit and 1 QCombobox, you have to assure that their focus policy have been set right. (Normally either Qt::TabFocus or Qt::StrongFocus will be set as default, but sometimes you might want to escape some widgets from being tabbed)
Second: go to designer mode and click "Edit Tab Order" to enter the tab-order editing mode
Third: After seeing the numbers, click on them until you got the desired sequence order.
(Picture from Qt official site)
Have a mouse press event or a event filter, get to the point where you have a QKeyEvent
Then only do something if tab was pressed
key_event->button() == Qt::Key_Tab
Mac have a capability to specify two default buttons, one activated by return and other by spacebar. One clear example is when you press power button on mac. It gives you a dialog box with quiet a few buttons, in which it shutdown is default for return key and restart is default for spacebar key. Is it possible to achieve such effect in Qt?
Yes.
Use QPushButton. On the "default" button use setDefault and setAutoDefault() to make them appear as a default button.
http://doc.trolltech.com/4.7/qpushbutton.html#default-prop
To handle the escape key (and possibly even the return key), you must set the shortcuts for each button to associate them with a corresponding key. It's easy to do that using Qt Creator/Designer.