Window size adjustment on Smartphone (Xperia Z2)



  • Hello there,

    since yesterday i have my first smartphone (i know, hard to believe), it´s a Xperia Z2 running on Android.
    With the help of the mighty internet I already could set up the toolchain to deploy Apps from desktop PC to Smartphone.
    I have trouble to adjust the proportions of the widgets. I really mean proportions, not absolute size, since i know it would depend on resolution.
    The proportions are completely different compared to when running on the desktop PC.

    I guess it´s something fundamental i´m not considering. Any suggestions?

    best regads,
    Moe

    PS.: had no ideas about useful keywords to search for...


  • Lifetime Qt Champion

    Hi,

    Can you show an image of what happens ?



  • How can i load a photo? Or is it only possible via a link?

    best regards,
    Moe



  • Ok, i´m home and loaded the fotos in DropBox

    As you can see in the picture, the red backround of the ui only exits under the slider and numbers. Also the black rectangle at the top has allways the same size and positions, no matter which values i use in setGeometry();

    The "App" itself
    https://www.dropbox.com/s/3fgewiqvebgqfye/Screenshot_2015-03-11-19-36-52.png?dl=0

    The ui
    https://www.dropbox.com/s/2zil29kewpfezvp/UI_QtCreator.jpg?dl=0

    The MainFile:

    #include <QTimer>
    #include <QWidget>
    #include <QApplication>
    #include "acc.h"
    #include <QVBoxLayout>
    #include <QScreen>
    #include <QGuiApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        QScreen* screen =  QApplication::screens().at(0);
        QWidget w;
    
        QWidget* testWidget = new QWidget;
        testWidget->setGeometry(0, 0, 50, 20);
        testWidget->setStyleSheet("background-color:black");
        //w.setBaseSize(100, 100);
    
        QTimer* timer = new QTimer();
        ACC* acc = new ACC();
        acc->screen = screen;
    
        QVBoxLayout* layout;
        layout = new QVBoxLayout(&w);
        layout->addWidget(testWidget);
        layout->addWidget(acc);
    
        QObject::connect(timer, SIGNAL(timeout()), acc, SLOT(triggerCap()));
        timer->start(10);
    
        w.show();//acc->show();
        a.exec();
        return 1;
    }
    

    [edit: added missing coding tags: 3 ` before and after SGaist]


  • Lifetime Qt Champion

    You put testWidget in a layout, that's why it won't have the geometry you set on it.

    How are you setting the red background ?



  • The background is set by a stylesheet "background-color:red" in the creator.
    Also when i set this by code, only the elements are underlayed with red.

    May be it´s some kind of property i need to set? I parsed them, but i´m not sure.



  • In between i made by code a widget with yellow background which contains 3 numbers.
    This works out. So i think it has something to do with the Widget Designer, some corresponding properties...

    https://www.dropbox.com/s/wcmro6j7bp6vgvz/Screenshot_2015-03-12-10-05-49.jpg?dl=0


  • Lifetime Qt Champion

    Did you set the red background on each separated widget or on the containing widget ?



  • On the containing widget.



  • I solved it by a workaround. That means, i don´t know if it´s a workaround, main thing is, it works.

    In the QtDesigner I put a normal blank widget on the Form at first and on top of that Widget the slider and Numbers. Now it´s solid painted.

    First i tried something with "setBackgroundRole(QPalette::ColorRole role)"


  • Lifetime Qt Champion

    It think I may have understood your problem. You didn't put your separated widgets in a layout ?


Log in to reply
 

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