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) › tablet phone detection

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #15858

    Bas

    hi i am using the following line in a script to set parameters for e.g. number of columns / rows/ fontsize etc.

    gameWindow.portrait ? ( gameWindow.tablet ? 3 : 2 ) : 4

    But it does not give me the desired results when i am in IOS simulator iPad Air / iPad Air 2

     

    #15859

    Bas
        Grid {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            anchors.verticalCenterOffset: ( gameWindow.portrait ? ( gameWindow.tablet ? 0 : 60 ) : 0 )
            spacing: gameWindow.portrait ? ( gameWindow.tablet ? 30 : 40 ) : 20
            columns: gameWindow.portrait ? ( gameWindow.tablet ? 3 : 2 ) : 4
    
    

     

    #15864

    Günther
    Felgo Team

    Hi Bas,

    I just did a short test and I can verify the issue on the simulator: GameWindow.tablet is incorrectly always set to false for every selected device.
    The error seems to be new with the latest Felgo update and switch to Qt 5.8.

    We will have a closer look – thanks for reporting the problem!

    Best,
    Günther

    #15868

    Bas

    hi Gunther,

    is there a convenient other function 4 the time being I could use?

    Greetz,

    Bas

     

    #15885

    Günther
    Felgo Team

    Hi Bas!

    You can use the Qt Screen Type to check the screen dimensions and do a rough estimation of the diameter to decide whether a tablet or phone is used:

    For example somehow like this:

    import Felgo 3.0
    import QtQuick.Window 2.2
    
    App {
      id: app
    
      property real screenDiameter: Math.sqrt(app.width * app.width + app.height * app.height)
      property real screenDiameterInMM: screenDiameter / Screen.pixelDensity
      property real screenDiameterInInches: screenDiameterInMM / 10 / 2.54
      property bool isTablet: app.screenDiameterInInches > 5.5
    
      // ...
    
    }

    The calculated diameter doesn’t seem to be 100% correct in my tests (please correct me if I made a mistake in the calculation), but the check at least does the trick for me during some quick tests in the simulator.

     

    Best,
    Günther

    #15891

    Bas

    hmm i love this support!

    thanx Gunther!

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

RSS feed for this thread

You must be logged in to reply to this topic.