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!

Forums

OverviewFelgo 2 Support (Qt 5) › window size change runtime customize

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16080

    Bas

    hi,

     

    is it posible to change the window size list, so i could add custom sizes?

    gr,

    Bas

    #16082

    Günther
    Felgo Team

    Hi Bas,

    we do not allow to modify the debug menu bar with custom resolutions at the moment.

    But you can implement your own solution with a small workaround:

    import Felgo 3.0
    import QtQuick 2.0
    import QtQuick.Window 2.2
    
    App {
      id: app
    
      // resize window on button click
      AppButton {
        text: "Resize Window"
    
        // properties of new target device (e.g. values that match iPhone 6)
        property real deviceWidth: 750
        property real deviceHeight: 1334
        property int deviceDpi: 326
    
        // set new window size and uiScale on button click
        onClicked: {
          // calculate scale-factor to fit window on screen if width/height too big for screen (for landscape or portrait)
          var targetWidth = app.width < app.height ? deviceWidth : deviceHeight
          var targetHeight = app.width < app.height ? deviceHeight : deviceWidth
          var windowScale = Math.min(Math.round(Screen.desktopAvailableWidth * 0.9) / targetWidth, Math.round(Screen.desktopAvailableHeight * 0.9) / targetHeight, 1.0)
    
          // set new size and uiScale
          app.setScreenSize(Math.round(targetWidth * windowScale), Math.round(targetHeight * windowScale)) // resize window
          app.uiScale = deviceDpi / (Screen.pixelDensity * 25.4) * windowScale // resize UI to match device dpi
        }
      }
    
    }
    

     

    Cheers,
    Günther

     

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

RSS feed for this thread

You must be logged in to reply to this topic.