[SOLVED] How can a button be left bottom and stay there on window resize..



  • So for now i have 4 buttons in a buttonlayout but i want 1 of the 4 buttons to be always left bottom not always right bottom...

    @ buttonsLayout = new QHBoxLayout;
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->help);
    buttonsLayout->addWidget(ui->cancel);
    buttonsLayout->addWidget(ui->test);
    buttonsLayout->addWidget(ui->apply);
    mainLayout = new QVBoxLayout;
    mainLayout->addWidget(optionsGroupBox);
    mainLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);@

    Maybe you understand what i want with this screenshot:
    !http://i.imgur.com/QcFaf.png(image)!



  • Hi,

    Did you try to put Horizontal spacer between Help and Cancel buttons?

    BR,



  • You need to addStretch() between Help and Cancel Button.

    @buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(ui->help);
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->cancel);
    buttonsLayout->addWidget(ui->test);
    buttonsLayout->addWidget(ui->apply);@



  • Ok i founded how to do it!

    Previous

    @buttonsLayout = new QHBoxLayout;
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->help);
    buttonsLayout->addWidget(ui->cancel);
    buttonsLayout->addWidget(ui->test);
    buttonsLayout->addWidget(ui->apply);
    mainLayout = new QVBoxLayout;@
    

    Solution

    @buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(ui->help);
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->cancel);
    buttonsLayout->addWidget(ui->test);
    buttonsLayout->addWidget(ui->apply);@


  • [quote author="Sam" date="1344941613"]You need to addStretch() between Help and Cancel Button.

    @buttonsLayout = new QHBoxLayout;
    buttonsLayout->addWidget(ui->help);
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->cancel);
    buttonsLayout->addWidget(ui->test);
    buttonsLayout->addWidget(ui->apply);@[/quote]

    You caught me!



  • Yeah I did :)


Log in to reply
 

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