Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Designing the Qt Classes for to Autofit UI contents according to screen Monitor size

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shan Vikram
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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)

      S 1 Reply Last reply
      5
      • mrjjM mrjj

        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)

        S Offline
        S Offline
        Shan Vikram
        wrote on last edited by
        #3

        @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.

        mrjjM 1 Reply Last reply
        2
        • S Shan Vikram

          @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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved