Important: Please read the Qt Code of Conduct -

QWidget for mobile dev?

  • Hello there, so I am facing a dilemma for my project. I have developed a desktop app which is using Qt Widget and the most the GUI is done through C++ code and it is working perfectly. But my problem is that I want to use to same code and develop and mobile app for it. Doing so, I am running into the problem of screen resolution. The app is not automatically adapting to my mobile screen size. I am aware that Qt has QML which is for mobile app development but what if I want to keep the same look and feel by using QWidget. Does anyone know how I could make it to automatically fit my mobile? I am new a newbie in the Qt platform. THanks for your help

  • Qt Widgets should be quite adaptive. First thing to check is that you don't specify any physical sizes or locations for the widgets, but place everything in a layout and let the layouts adapt to the small size.

    But if that doesn't work you may need to resort to setting rules if the screen is "small", like yourwidget->setMaximumWidth() and so on.

  • An iPad's logical pixel resolution is 768x1024 and an iPhone's is a few hundred by a few hundred. What happens if you set your desktop app to start up at that size? Is it doing the same as you're seeing on mobile? Note that if you perform your own pixel calculations, it's sometimes possible to get confused by details of HDPI (ie "retina") "device pixels" leaking into the "logical pixels" domain. I'd have hoped widgets were fairly immune to that though... more of a problem with native OpenGL.

  • @timday I manually did specify the resolution as you mentioned but it's adapting on the Iphone 7 plus but not on the 7. one is 5.5 and the other is 4.7 sadly

Log in to reply