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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support