Custom TextFieldStyle for iOS application
-
Hi,
I would like to modify the style of TextField in an iOS application. Here is the code:
TextField { style: TextFieldStyle { background: Item { } } }
That will clear the border of the text field. However, it will also unset the selection handle . It won't show the popup of "paste | select | selection all". That is not what I need.
I have checked the source code of Qt. The parameter for selection handle is defined in QtQuick.Controls.Styles.IOS.TextFieldStyle , but they are private. I can not declare a TextFieldStyle to inherit iOS.TextFieldStyle.
So my question is , what is the preferred way to modify the style of a control component for iOS platform? e.g copy the private header to my program?
Thanks.
-
Hi benlau,
Unfortunatly, I don't think that there is a prefered way modify a style of a specific platform.
What you could do (but it's really a hack) is something like this:
Add
import "qrc:/QtQuick/Controls/Styles/iOS" (or)
import "file:/QtQuick/Controls/Styles/iOS"
Remove the
import QtQuick.Controls.Style 1.0
This will import the iOS style objects and you can modify it like in your code above. -
hi jseeQt,
Thank for your reply. Too bad , it don't have any preferred/standard method.. I don't mind for a hack solution. However, my code is not executed in iOS only. It also run on desktop / Linux for preview and automated test.
The desktop build won't bundle those qml files into qrc. That means the import path of desktop and iOS will be different. I still need a way to detect the location of qml plugin , inherit the TextFieldStyle and modify it.