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. [SOLVED] What should i do to resize the dialog the proper way?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] What should i do to resize the dialog the proper way?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 2.8k 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    So i have this dialog,

    !http://i.imgur.com/O4hye.png(Image 1)!

    the arrow thing is a checkbox and when you click it:

    !http://i.imgur.com/tpfgG.png(Image 2)!

    when you click it back (uncheck)

    !http://i.imgur.com/uvebp.png(Image 3)!

    And this is ugly not resizing the dialog back like image 1. Am i right? So i have no idea how to do it because ->resize won't work in this case.
    My code creating the dialog

    @ createOptionsGroupBox();
    createButtonsLayout();
    mainLayout = new QVBoxLayout;
    mainLayout->addWidget(optionsGroupBox);
    mainLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);

    void custom_command::createOptionsGroupBox()
    {
    optionsGroupBox = new QGroupBox();
    optionsGroupBoxLayout = new QGridLayout;
    optionsGroupBoxLayout->addWidget(ui->label, 0, 0, 2, 2);
    optionsGroupBoxLayout->addWidget(ui->label_2, 2, 0);
    optionsGroupBoxLayout->addWidget(ui->de, 2, 1);
    optionsGroupBoxLayout->addWidget(ui->checkBox, 3,0);
    optionsGroupBoxLayout->addWidget(ui->label_4, 4, 0);
    optionsGroupBoxLayout->addWidget(ui->command, 5, 0);
    optionsGroupBoxLayout->addWidget(ui->label_5, 6, 0);
    optionsGroupBoxLayout->addWidget(ui->label_6, 7, 0);
    optionsGroupBoxLayout->addWidget(ui->add_argument, 8, 1);
    optionsGroupBoxLayout->addWidget(ui->rmButton, 9, 1);
    optionsGroupBoxLayout->addWidget(ui->clear, 10, 1);
    optionsGroupBoxLayout->addWidget(ui->listWidget, 8, 0, 3, 1);
    optionsGroupBox->setLayout(optionsGroupBoxLayout);
    }

    void custom_command::createButtonsLayout()
    {
    buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(ui->help);
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->cancel);
    buttonsLayout->addWidget(ui->test);
    buttonsLayout->addWidget(ui->apply);
    }@

    And i use ->hide and ->show to work with the checkbox

    1 Reply Last reply
    0
    • A Offline
      A Offline
      adam.bogocz
      wrote on last edited by
      #2

      You could use QPropertyAnimation and animate resizion of the whole dialog. You could save the geometry before it expands into the animation.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        Yeah but i can't resize it.. I have noooo idead why i can't resize it:

        @if(!this->isMaximized())
        this->resize(QSize(this->width(),this->height()-200));@

        The reason must be something about the groubox.. Anyone can give me a hint?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          adam.bogocz
          wrote on last edited by
          #4

          so you cannot resize it from CPP and also by mouse?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CreMindES
            wrote on last edited by
            #5

            You should take a look at shape-changing dialogs in C++ GUI Programming with Qt4 Second Edition. ;)

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goblincoding
              wrote on last edited by
              #6

              I had a similar problem that I solved by inserting a vertical spacer item in between (in your case) the "Show Details" button and the details you're showing. In other words

              //-------------------informative text here -------------------//
              //
              //

              Show Details
              //----------------------vertical spacer----------------------//
              // Command...etc etc etc
              // Help and other buttons

              I then connected the "Show Details" button clicked() signal to a slot that simply hides or shows the widget containing the information that should be visible/not visible.

              Something like:

              @
              void Widget::toggleVisibility()
              {
              if( customComand->isVisible() )
              {
              customComand->hide();
              showDetailsButton->setArrowType( Qt::DownArrow );
              } else {
              customComand->show();
              showDetailsButton->setArrowType( Qt::RightArrow );
              }
              }
              @

              I hope this makes sense.

              http://www.goblincoding.com

              1 Reply Last reply
              0
              • C Offline
                C Offline
                ChrisW67
                wrote on last edited by
                #7

                Take a look at the Extension Example in Qt Assistant. The resizing magic is:

                @
                mainLayout->setSizeConstraint(QLayout::SetFixedSize);
                @

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Leon
                  wrote on last edited by
                  #8

                  well i read "shape-changing dialogs in C++ GUI Programming with Qt4 Second Edition"
                  and it solved my problem :)

                  i just had to make a second groubox which consisted the widgets that i wanted to hide/show..
                  Thank you for your answers! :)

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goblincoding
                    wrote on last edited by
                    #9

                    Maybe I should take a look at "Shape-changing dialogs in C++ GUI Programming with Qt4 Second Edition" also! :)

                    http://www.goblincoding.com

                    1 Reply Last reply
                    0

                    • Login

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