Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

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

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

    Marek

    Hi

    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

     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: {
            Style.buttonHeight=dp(30)

    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

    Marek

    #23951

    Marek

    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

     App{
        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)
    

    Best,

    Marek

    #23952

    Filippo

    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: https://felgo.com/doc/apps-howto-style-your-app-with-themes/

     

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

     

    Cheers.

    #23953

    Marek

    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

    Marek

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

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded