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. unchanged positions of controls in main window
Forum Updated to NodeBB v4.3 + New Features

unchanged positions of controls in main window

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 548 Views
  • 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.
  • R Offline
    R Offline
    Robert M.
    wrote on last edited by
    #1

    I have a windows mainwindow.ui that contains a number of controls. I changed positions of controls in the window. After I compiled my project I run it and I see main window with previous positions of controls (they are unchanged). What could be a reason new position are not visible?
    Please help. I use Qt5 and Qt Creator 6.0.1.

    jsulmJ 1 Reply Last reply
    0
    • R Robert M.

      I have a windows mainwindow.ui that contains a number of controls. I changed positions of controls in the window. After I compiled my project I run it and I see main window with previous positions of controls (they are unchanged). What could be a reason new position are not visible?
      Please help. I use Qt5 and Qt Creator 6.0.1.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Robert-M Do you use layouts? Usually you should not position widgets manually.
      Try a complete rebuild: delete build folder, run qmake and build.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Robert-M Do you use layouts? Usually you should not position widgets manually.
        Try a complete rebuild: delete build folder, run qmake and build.

        R Offline
        R Offline
        Robert M.
        wrote on last edited by
        #3

        @jsulm
        Deleting folder and rebuild didn't help.

        jsulmJ 1 Reply Last reply
        0
        • R Robert M.

          @jsulm
          Deleting folder and rebuild didn't help.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Robert-M You still did not say whether you're using layouts.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Robert-M You still did not say whether you're using layouts.

            R Offline
            R Offline
            Robert M.
            wrote on last edited by
            #5

            @jsulm
            No, I don't use layout.
            I am starting learning layouts.

            jsulmJ 1 Reply Last reply
            0
            • R Robert M.

              @jsulm
              No, I don't use layout.
              I am starting learning layouts.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Robert-M Well, it should work.
              Did you save the file after changing the positions of the widgets?
              Is this ui file really used?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              R 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Robert-M Well, it should work.
                Did you save the file after changing the positions of the widgets?
                Is this ui file really used?

                R Offline
                R Offline
                Robert M.
                wrote on last edited by
                #7

                @jsulm
                I failed to solve my problem using layouts. And I think I don't need a layout in my main window - my problem is simple.
                I continue previous approach.
                I have a text box and labeled button below text box.
                I defined method:

                void MainWindow::resizeEvent(QResizeEvent *event)
                {
                int delta = event->size().height() - event->oldSize().height();
                QMainWindow::resizeEvent(event);
                // ui->command_text->resize(this->width() - 40, ui->command_text->height() + delta);
                ui->label_2->move(ui->label_2->x(), ui->label_2->y() + delta);
                ui->pushButton_obfuscate->move(ui->pushButton_obfuscate->x(), ui->pushButton_obfuscate->y() + delta);
                }

                The problem is that in my program with this method I don't see labeled button on the screen - only text box is displayed. I don't know why - what is wrong with my method. Please help to correct resizeEvent method's code - this would solve my problem.

                R 1 Reply Last reply
                0
                • R Robert M.

                  @jsulm
                  I failed to solve my problem using layouts. And I think I don't need a layout in my main window - my problem is simple.
                  I continue previous approach.
                  I have a text box and labeled button below text box.
                  I defined method:

                  void MainWindow::resizeEvent(QResizeEvent *event)
                  {
                  int delta = event->size().height() - event->oldSize().height();
                  QMainWindow::resizeEvent(event);
                  // ui->command_text->resize(this->width() - 40, ui->command_text->height() + delta);
                  ui->label_2->move(ui->label_2->x(), ui->label_2->y() + delta);
                  ui->pushButton_obfuscate->move(ui->pushButton_obfuscate->x(), ui->pushButton_obfuscate->y() + delta);
                  }

                  The problem is that in my program with this method I don't see labeled button on the screen - only text box is displayed. I don't know why - what is wrong with my method. Please help to correct resizeEvent method's code - this would solve my problem.

                  R Offline
                  R Offline
                  Robert M.
                  wrote on last edited by
                  #8

                  @Robert-M
                  The code without this method shows labeled button.
                  When I added this method, the labeled button is not displayed.
                  In this method I want to move the labeled button down/up depending on resizing main window.

                  jsulmJ 1 Reply Last reply
                  0
                  • R Robert M.

                    @Robert-M
                    The code without this method shows labeled button.
                    When I added this method, the labeled button is not displayed.
                    In this method I want to move the labeled button down/up depending on resizing main window.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Robert-M Did you check the value of delta? Maybe it is too big?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    R 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Robert-M Did you check the value of delta? Maybe it is too big?

                      R Offline
                      R Offline
                      Robert M.
                      wrote on last edited by
                      #10

                      @jsulm
                      Bingo!
                      delta == 279
                      But I don't know why - I have a problem with debuuger now and I can't watch .height()
                      How to program it?:
                      int delta = event->size().height() - event->oldSize().height();

                      R 1 Reply Last reply
                      0
                      • R Robert M.

                        @jsulm
                        Bingo!
                        delta == 279
                        But I don't know why - I have a problem with debuuger now and I can't watch .height()
                        How to program it?:
                        int delta = event->size().height() - event->oldSize().height();

                        R Offline
                        R Offline
                        Robert M.
                        wrote on last edited by
                        #11

                        @Robert-M
                        oldSize.height was -1 at initial call of the method.
                        Problem solved!!!

                        1 Reply Last reply
                        1

                        • Login

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