Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!


OverviewFelgo 2 Support (Qt 5) › setting initial width/height of the UI components

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #23950



    I want to set some initial height of the UI elements eg. AppButton and I want to use this height through different UI elements of the app.

    So I have Style.qml which is Singleton

    pragma Singleton
    import Felgo 3.0
    import QtQuick 2.12
    Item {
        property double buttonHeight:dp(30)

    However I can’t set dp(30) here because it says  ReferenceError: dp is not defined

    I can’t set it at the beginning of the App

        id: app
        Style.buttonHeight: dp(30)

    because it says:  Non-existent attached object

    I’m setting it at the end of Main

    Component.onCompleted: {

    which is fine for Desktop, but it causes mobile app to blink/resize on startup

    Question: what is recommended way of using dp() function , so I could set size of the UI elements on startup and have it available in all components ?

    Now I’m using import “style” in other qml files and I can set eg height:Style.buttonHeight but app blink/resize on startup

    Best Regards




    Well, maybe after all it wasn’t wise question 😉

    I’m setting sizes of elements at the beginning of the app and Style singleton is for changing color theme of the UI

        id: app
        property int buttonHeight:dp(30)
        property double buttonRadius: buttonHeight * 0.5
        property bool on_phone:((Qt.platform.os == "android" || Qt.platform.os == "ios") && !tablet ? true : false)




    Felgo Team

    Hi Marek,


    yes, the global property in App, or a global QtObject with the desired properties should do the trick.


    If you’re looking into styling components I’d also suggest taking a look at here:


    It’s probably the easiest way to theme your app.





    Thanks for answer,

    I am using Theme in some of my apps, but now I have custom buttons and everything, and different icons for different color schemes

    Best Regards


Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.