Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml resuable component best practice

Qml resuable component best practice

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlqtquick
5 Posts 4 Posters 629 Views
  • 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.
  • V Offline
    V Offline
    VinayBalajiRajputh
    wrote on last edited by
    #1

    Hello everyone,

    I am writing an application and for this I need 3 pages at the beginning depending upon user selections and also some minor logic changes. How do i encapsulate the elements? Should i create a single component i.e. mycom.qml and then in 3 pages create 3 objects and rewrite logic in handling on text changed? Or should i encapsulate just elements?

    I have attached image for better understanding
    image_!.png

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      It is better to create one re-usable component & 3 objects & adjust the logic to create the UI.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      V 1 Reply Last reply
      2
      • dheerendraD dheerendra

        It is better to create one re-usable component & 3 objects & adjust the logic to create the UI.

        V Offline
        V Offline
        VInay123
        wrote on last edited by
        #3

        @dheerendra
        So you mean, in one qml file one whole page as shown in image and create 3 more objects out of this component?
        But then i would have to implement logic for text edits in all 3 objects therefore in main component i have to expose all elements via property alias.. is this a good workflow?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Yes. It is right work-flow.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            @VInay123 said in Qml resuable component best practice:

            implement logic for text edits in all 3 objects

            You can put redundant/common logic in a separate js file that is imported in each qml file that it is needed. That should help reduce the logic footprint.

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved