Designing the Qt Classes for to Autofit UI contents according to screen Monitor size



  • Hi All,

    am very new to Qt, If am wrong in my understanding please guide me to correct myself.
    

    I need to design the QT classes to Autofit UI contents according to connected monitor size.

    In mainwindow I need to show IP address, cloud and Printer connected status. It also have Home button , Alerts, settings buttons where it can show details of Alerts messages and setting details of the device. In General in Home button scope I need to display status (Operative, Inoperative,Running) of devices those all are configured in my system, say some pump and Terminal devices .

    my design as of now:

    class MainWindow : public QMainWindow
    {

    private slots:

    void on_HomeButton_clicked();

    void on_SettingsButton_clicked();
    
    void on_AlertsButton_clicked();
    

    void on_DateTime_clicked();

    private:

    /* Below all object pointers from Inhertied from QFrame class */
    PumpandTerminalStatus *ps;
    settings *stgs;
    DateTime *dt;
    Alerts *alerts;

    }

    class settings : public QFrame
    {

    }

    namespace Ui {
    class PumpandTerminalStatus;
    }

    class PumpandTerminalStatus :public QFrame
    {
    public:
    void UpdatePumpStatus();

    void UpdateTrmStatus();
    

    private:

    Ui::PumpandTerminalStatus *ui;

    }

    Currently to achieve my Autofit task , I just using QRect screenGeometry = QApplication::desktop()->availableGeometry(); and able to get details of monitor and maunpualting maunally width and height for Qpushbutton and QLable used in Mainwindow and passing same information to PumpandTerminalStatus class (ps->SetScreenSizeInfo(mscreenWidth,mscreenHeight)) so that Qpushbutton and QLabel under this class can also resize according to this inforamtion.

    I like to know instead of this manual calcualtion, is there any other best method I can able to adopt.

    Still facing some problem though followed manual calculation method .

    When I click settings button it shows the details and then after Home button , application is crashing.

    Minimize and Maxmize for mainwindow is not working properly.


  • Qt Champions 2016

    Hi
    Layouts are ment for auto fitting.
    http://doc.qt.io/qt-5/layout.html

    The remove the need to manually alter size for elements if mainwindow size changes.
    You can specify min and max pr widget to tweak the auto scaling and they offer many
    tweaking options. ( like margins etc)



  • @mrjj said in Designing the Qt Classes for to Autofit UI contents according to screen Monitor size:

    http://doc.qt.io/qt-5/layout.html

    Thanks for your information, I will follow your link and update you further.


  • Qt Champions 2016

    @Shan-Vikram
    Hi
    as an intro , video can also be helpful
    https://www.youtube.com/watch?v=gWa2rqe8l6E
    To see what layout do.


Log in to reply
 

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