App looks fine on Desktop, but not iOS emulator



  • The emulator is trying to look exactly like the Desktop app, instead of resizing all the images to make it proportional, I guess like an autofit. Anyone have an idea on how I can achieve this?


  • Moderators

    It is your responisibility to make the images resize as you wish to, there are some helper classes available. Qt does not do that automatically. The idea in Qt is to have something look the same on all platforms.



  • you should define all based on screen values gathered due runtime. i use the following way, after initiliazing the ui (ui->setupUi(this);):

    @screen = QGuiApplication::screens().first();
    connect(screen, SIGNAL(virtualGeometryChanged(QRect)), this, SLOT(setSizes()));@

    @void MainWindow::setSizes()
    {
    int height = screen->availableSize().height();
    ui->backButton->setIconSize(QSize(height/10, height/10));
    ui->menuButton->setIconSize(QSize(height/10, height/10));
    }@

    Looks great on any device size, tho I do allow the user to modify the values later via settings. You can use a modified function to apply it to images or whatever...



  • [quote author="dominik.fehr" date="1407944460"]you should define all based on screen values gathered due runtime. i use the following way, after initiliazing the ui (ui->setupUi(this);):

    @screen = QGuiApplication::screens().first();
    connect(screen, SIGNAL(virtualGeometryChanged(QRect)), this, SLOT(setSizes()));@

    @void MainWindow::setSizes()
    {
    int height = screen->availableSize().height();
    ui->backButton->setIconSize(QSize(height/10, height/10));
    ui->menuButton->setIconSize(QSize(height/10, height/10));
    }@

    Looks great on any device size, tho I do allow the user to modify the values later via settings. You can use a modified function to apply it to images or whatever...[/quote]

    Apologies as I'm really raw to QT. What are screen, backButton, and menuButton? When i make the setSizes function, it would be whatever my project name is::setsizes()?



  • screen is a QScreen object.

    @QScreen *screen;@

    backButton and menuButton are QPushButtons, implemented via the QtDesigner.
    If you are working with the designer, you can reach any UI element via:

    ui->[ui object name]

    setSizes is a function of my main class, aka MainWindow. You need to modify the function for your needs, the only important thing I wanted to show is that you need to work with the available screen size of your device to make your app fit :)

    Best regards



  • I've gotten the code to work, but it looks weird. How do I get the dimensions to this?!http://i.imgur.com/PkrrWEq.png()!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.