Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Custom TextFieldStyle for iOS application

    Mobile and Embedded
    2
    3
    641
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • benlau
      benlau Qt Champions 2016 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • J
        jseeQt last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • benlau
          benlau Qt Champions 2016 last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post