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. GUI was not proper for all resolutions
Forum Updated to NodeBB v4.3 + New Features

GUI was not proper for all resolutions

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.4k Views 1 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.
  • A Offline
    A Offline
    Apeksha
    wrote on last edited by
    #1

    Hi,

    I am using three QGroupbox in QHBoxLayout, and my groupboxes shout not resize it should be constans for that i am setting setFixedSize, but this was effecting GUI when I am running in other resolutions.
    My resolution is 1600x900, here it was proper, but when running in 1920x1280 it was not proper, groupboxes getting smaller and gui doesn't look good.You can see following code for reference:
    QHBoxLayout *connectionLayout = new QHBoxLayout;
    connectionLayout->setSpacing(2);
    ui->connectionBox->setMinimumSize(160,150);
    ui->connectionBox->setMaximumSize(160,150);
    ui->ProgrammerBox->setMinimumSize(320,150);
    ui->ProgrammerBox->setMaximumSize(320,150);
    ui->powerBox->setMinimumSize(330,150);
    ui->powerBox->setMaximumSize(330,150);
    connectionLayout->addWidget(ui->connectionBox);
    connectionLayout->addWidget(ui->ProgrammerBox);
    connectionLayout->addWidget(ui->powerBox);
    // connectionLayout->setSizeConstraint(QLayout::SetFixedSize);
    mainBoxLayout->addLayout(connectionLayout);

    Thanks in advance.

    VRoninV 1 Reply Last reply
    0
    • A Apeksha

      Hi,

      I am using three QGroupbox in QHBoxLayout, and my groupboxes shout not resize it should be constans for that i am setting setFixedSize, but this was effecting GUI when I am running in other resolutions.
      My resolution is 1600x900, here it was proper, but when running in 1920x1280 it was not proper, groupboxes getting smaller and gui doesn't look good.You can see following code for reference:
      QHBoxLayout *connectionLayout = new QHBoxLayout;
      connectionLayout->setSpacing(2);
      ui->connectionBox->setMinimumSize(160,150);
      ui->connectionBox->setMaximumSize(160,150);
      ui->ProgrammerBox->setMinimumSize(320,150);
      ui->ProgrammerBox->setMaximumSize(320,150);
      ui->powerBox->setMinimumSize(330,150);
      ui->powerBox->setMaximumSize(330,150);
      connectionLayout->addWidget(ui->connectionBox);
      connectionLayout->addWidget(ui->ProgrammerBox);
      connectionLayout->addWidget(ui->powerBox);
      // connectionLayout->setSizeConstraint(QLayout::SetFixedSize);
      mainBoxLayout->addLayout(connectionLayout);

      Thanks in advance.

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @Apeksha said in GUI was not proper for all resolutions:

      my groupboxes shout not resize

      instead of using setMinimumSize and setMaximumSize could you try using setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);? that should look good on all resolutions and not expand/shrink.

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      A 1 Reply Last reply
      0
      • VRoninV VRonin

        @Apeksha said in GUI was not proper for all resolutions:

        my groupboxes shout not resize

        instead of using setMinimumSize and setMaximumSize could you try using setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);? that should look good on all resolutions and not expand/shrink.

        A Offline
        A Offline
        Apeksha
        wrote on last edited by
        #3

        @VRonin said in GUI was not proper for all resolutions:

        setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);

        thank you for response.
        it's not working

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Apeksha
          wrote on last edited by
          #4

          this is my actual gui code:

          MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
          {
          ui->setupUi(this);
          // QRect screenSize = desktop.availableGeometry(this);
          // this->resize(QSize(screenSize.width * 0.7f, screenSize.height * 0.7f));
          // qDebug()<<"screen geometry is"<<screenGeometry;
          // QDesktopWidget dw;
          // int x=dw.width();
          // int y=dw.height();
          ui->centralWidget->setStyleSheet("background-color:rgb(221, 221, 221)");
          ui->menuBar->setStyleSheet("QMenuBar{background-color:rgb(221, 221, 221)} QMenu:hover {background-color:white; selection-color:white;}");
          ui->modeComboBox->addItem("Secured1");
          ui->modeComboBox->addItem("Secured2");

          timer = new QTimer(this);
          upgradetimer = new QTimer(this);
          uploadtimer = new QTimer(this);
          canceltimer = new QTimer(this);
          programtimer = new QTimer(this);
          

          #if 1

          QHBoxLayout *mainLayout = new QHBoxLayout;
          
          mainLayout->setSpacing(5);
          ui->MainBox->setAlignment(Qt::AlignTop);
          mainLayout->addWidget(ui->MainBox);
          mainLayout->addWidget(ui->txtLog);
          ui->txtLog->setReadOnly(true);
          QScrollBar *sb = ui->txtLog->horizontalScrollBar();
          ui->txtLog->setLineWrapMode(QTextEdit::NoWrap);
          sb->setValue(sb->maximum());
          ui->centralWidget->setLayout(mainLayout);
          
          QVBoxLayout *mainBoxLayout= new QVBoxLayout;
          mainBoxLayout->setSpacing(0);
          QWidget *topWidget = new QWidget;
          QVBoxLayout *step1Layout = new QVBoxLayout(topWidget);
          step1Layout->setSpacing(1);
          step1Layout->addStretch(0);
          ui->label_1->setMinimumSize(100,10);
          ui->label_1->setMaximumSize(100,10);
          ui->line->setMaximumSize(811,15);
          ui->line->setMinimumSize(811,15);
          step1Layout->addWidget(ui->label_1,0,Qt::AlignTop);
          step1Layout->addWidget(ui->line,0,Qt::AlignTop);
          

          // topWidget->setFixedHeight(30);
          topWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          mainBoxLayout->addWidget(topWidget);

          QHBoxLayout *connectionLayout = new QHBoxLayout;
          connectionLayout->setSpacing(2);
          

          // ui->connectionBox->setMinimumSize(160,150);
          // ui->connectionBox->setMaximumSize(160,150);
          // ui->ProgrammerBox->setMinimumSize(320,150);
          // ui->ProgrammerBox->setMaximumSize(320,150);
          // ui->powerBox->setMinimumSize(330,150);
          // ui->powerBox->setMaximumSize(330,150);

           ui->connectionBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
            ui->ProgrammerBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
             ui->powerBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          connectionLayout->addWidget(ui->connectionBox);
          connectionLayout->addWidget(ui->ProgrammerBox);
          connectionLayout->addWidget(ui->powerBox);
          mainBoxLayout->addLayout(connectionLayout);
          
          
          QWidget *top2Widget = new QWidget;
          QVBoxLayout *step2Layout = new QVBoxLayout(top2Widget);
          step2Layout->setSpacing(1);
          step2Layout->addStretch(0);
          step2Layout->addWidget(ui->label_2);
          step2Layout->addWidget(ui->line_2);
          

          // top2Widget->setFixedHeight(33);
          top2Widget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          mainBoxLayout->addWidget(top2Widget);

          // ui->contentWidget->setMinimumSize( 820, 200 );
          ui->contentWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
          QScrollArea *scrollArea = new QScrollArea;
          // scrollArea->setStyleSheet("QScrollArea {background-color:#C0C0C0;}");
          scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
          scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
          scrollArea->setWidget(ui->contentWidget);
          scrollArea->setWidgetResizable(true);
          ConfigurationLayout->addWidget(scrollArea);
          mainBoxLayout->addLayout(ConfigurationLayout);

          QWidget *top3Widget = new QWidget;
          QVBoxLayout *step3Layout = new QVBoxLayout(top3Widget);
          step3Layout->setSpacing(1);
          step3Layout->addStretch(1);
          step3Layout->addWidget(ui->label_3);
          step3Layout->addWidget(ui->line_3);
          

          // top3Widget->setFixedHeight(33);
          top3Widget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          mainBoxLayout->addWidget(top3Widget);

          QHBoxLayout *operationLayout = new QHBoxLayout;
          

          // ui->operationBox->setMinimumSize(820,195);
          ui->operationBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          //ui->operationBox->setMaximumSize(820,195);
          operationLayout->addWidget(ui->operationBox);
          mainBoxLayout->addLayout(operationLayout);
          ui->MainBox->setLayout(mainBoxLayout);

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Apeksha
            wrote on last edited by
            #5

            Hi
            Can we set default resolution as 1600x900 in qt app, so it works fine in all resolutions.
            How to set it?

            mrjjM 1 Reply Last reply
            0
            • A Apeksha

              Hi
              Can we set default resolution as 1600x900 in qt app, so it works fine in all resolutions.
              How to set it?

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

              @Apeksha

              In mainwindow, you can do
              setFixedSize(1600, 900);
              or
              resize(1600, 900);

              depending on what you want.

              If you set fixed size, then user with a screen of 1366x768
              might not be not be able to use your app.

              1 Reply Last reply
              2

              • Login

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