Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Rescale the mainwindow and its contents to fit in different screens



  • Hi guys,

    I am new to Qt. I have developed an application using Qt widget Application. In Mainwindow class I have several tablewdigets and textEdit and etc. In my computer it looks good (since I have used the designer to create the GUI). However, I want to port my application to Android. Since the screen size is different, I just want to know, how I should scale the whole mainwindow and its contents to occupy X% and Y% of any screen? I know I can use QWdiget::resize() function to resize my mainwindow but as expected the contents of my mainwindow remain fixed after scaling, how can I change their sizes as well?

    Thanks a bunch.



  • No reply for this? :( . I have been searching for the answer. It seems that its recommended to use Qt Quick Application or QML instead of Qt c++ codes. I am new to Qt and have created my projects using Qt Widget Application. Isn't that possible to somehow manage the issue without having to transfer all the codes to a new format?

    Thanks,


  • Lifetime Qt Champion

    Hi,

    How are you setting up your widgets ? Through QVBoxLayout & QHBoxLayout ?



  • Hi SGaist,

    Yes. I actually put lots of Vertical & Horizontal Spacer as well. But the whole windows are screwed! Any help is much appreciated!


  • Lifetime Qt Champion

    Lots of spacers ? What for ?



  • OK, I have attached a snapshot of my project ui here. Maybe this can help more. Its a very simple design. Just couple of QTablewidgets and a Qlabel to show an Image...
    In my desktop computer I can see all the windows just fine. I would like to have the same abilities in android mobiles and tablets with different screen resolutions.

    Thanks SGaist,
    Amir

    "Your text to link here...":https://www.dropbox.com/s/1fkhv3ztvtjekjb/project_snapshot.png?dl=0



  • I have removed all the layouts and spacers here.


  • Lifetime Qt Champion

    Looks like a work for QGridLayout


Log in to reply