.ui.qml use or not



  • Hello.
    I need little more information about correct usage of double file components (fooComponent.qml + fooComponent.ui.qml).

    As I understand, .ui.qml is for declarative usage in Designer. And it's .qml for logic implementation.
    So .ui.qml I can use for prototyping with static positioning and sizing (using magic numbers) and replace it by anchors positioning and dynamic sizing.

    But I can work this way and with single file components (.qml) in Designer.

    Could you clarify about .ui.qml usage? Need I this one or not?
    And one more question. May be I can fix positioning and sizining in single file components by using any tools like dev tools in web browsers?



  • @risky

    As I understand, .ui.qml is for declarative usage in Designer. And it's .qml for logic implementation.

    Pretty much yes.

    So .ui.qml I can use for prototyping with static positioning and sizing (using magic numbers) and replace it by anchors positioning and dynamic sizing.

    I didn't understand that. You can use anchors and dynamic sizing with Layouts in the Design view of Qt Creator as well as you can use fixed numbers.

    Could you clarify about .ui.qml usage? Need I this one or not?

    No you don't necessarily need it. It's up to you if you find it worth it. If you want to use the Design view for all components you may need to separate logic from the declarative part because the Design view can't handle all javascript code. Personally I have found it easier to design some more complex visual components so that the logic is separate but mostly I have ended up editing the declarative code manually and incorporating javascript directly there. So I have done visual prototyping with the Design view but continued with manual coding and one file per component.

    And one more question. May be I can fix positioning and sizining in single file components by using any tools like dev tools in web browsers?

    Do you mean you want to test changes of values run-time? It's possible with the QML debugger. You can see the QML object tree and change for example integer, boolean or text values on the fly. (I'm not sure if this is possible with older versions of Creator.)


  • Moderators

    I think the .ui.qml files were only introduced because it's easy to create a holy mess by mixing declarative ui stuff with lots of javascript.



  • @Eeli-K
    Thank you. I guess I understood purpose of file separation, but not sure if it so convenient.
    I had troubles with markup in Designer when I tried to create grid of inputs using Row and Column with anchors in double file component.
    I did not have any errors in Designer when set horizontal anchors in Row. But result looks like with broken markup.
    And with single file component I see error:

    qrc:/Dictionaries/UserEdit.qml:28:9: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.

    Therefore now I also consider it convenient use Designer and text editor both with single file component as you wrote.

    Do you mean you want to test changes of values run-time? It's possible with the QML debugger. You can see the QML object tree and change for example integer, boolean or text values on the fly.

    Yes. QML debugger works good this way. But I feel need in element picker when I want change properties of components in run-time.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.