Hi,
I'am having a problem in my code. I used addSpacing() and SeFixedSized(), to fix the buttons in my code. But the problem is once i enlarge the window, the buttons stay the same size and they dont get bigger with the same ratio as the window. I would appreciate any assistance on how i can fix this problem.
This is my code:
#include <QLabel>
#include <QPushButton>
#include <QProgressBar>
#include <QLineEdit>
#include <QIcon>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QToolButton>
#include <QApplication>
#include "auto.h"
{
// Title of the window
this->setWindowTitle("Main Menu");
this->resize(500, 350); // I'm using your old values
b_start->setFixedSize(70,30);
b_exit->setFixedSize(50,30);
l_welcome
= new QLabel(tr
("--Automatic Interface--"));
l_welcome
->setFont
(QFont("Times",
18,
QFont::Bold));
l_welcome->setAlignment(Qt::AlignCenter);
l_load
= new QLabel(tr
("Load Images"));
l_load->setAlignment(Qt::AlignLeft);
t_text->setFixedSize(150,20);
p_prog->setFixedSize(100,20);
v_1->setAlignment(Qt::AlignLeft);
v_1->addWidget(l_load);
v_1->addSpacing(10);
v_1->addWidget(t_text);
v_1->addWidget(t_browse);
v_1->addSpacing(20);
v_1->addWidget(p_prog);
v_2->setAlignment(Qt::AlignCenter);
v_2->addWidget(b_start);
v_2->addWidget(b_exit);
layout_vert->setAlignment(Qt::AlignCenter);
layout_vert->addWidget(l_welcome);
layout_vert->addSpacing(30);
layout_vert->addLayout(v_1);
layout_vert->addSpacing(30);
layout_vert->addLayout(v_2);
this->setLayout(layout_vert);
}
#include <QLabel>
#include <QPushButton>
#include <QProgressBar>
#include <QLineEdit>
#include <QIcon>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QToolButton>
#include <QApplication>
#include "auto.h"
Auto::Auto(QWidget *parent) : QWidget(parent)
{
// Title of the window
this->setWindowTitle("Main Menu");
this->resize(500, 350); // I'm using your old values
b_start = new QPushButton(tr("START/STOP"));
b_exit = new QPushButton(tr("Exit"));
b_start->setFixedSize(70,30);
b_exit->setFixedSize(50,30);
l_welcome = new QLabel(tr("--Automatic Interface--"));
l_welcome->setFont(QFont("Times", 18, QFont::Bold));
l_welcome->setAlignment(Qt::AlignCenter);
l_load = new QLabel(tr("Load Images"));
l_load->setFont(QFont("Times", 12, QFont::Bold));
l_load->setAlignment(Qt::AlignLeft);
t_text = new QLineEdit(this);
t_text->setFixedSize(150,20);
t_browse = new QToolButton(this);
p_prog = new QProgressBar(this);
p_prog->setFixedSize(100,20);
QHBoxLayout *v_1 = new QHBoxLayout;
v_1->setAlignment(Qt::AlignLeft);
v_1->addWidget(l_load);
v_1->addSpacing(10);
v_1->addWidget(t_text);
v_1->addWidget(t_browse);
v_1->addSpacing(20);
v_1->addWidget(p_prog);
QVBoxLayout *v_2 = new QVBoxLayout;
v_2->setAlignment(Qt::AlignCenter);
v_2->addWidget(b_start);
v_2->addWidget(b_exit);
QVBoxLayout *layout_vert = new QVBoxLayout;
layout_vert->setAlignment(Qt::AlignCenter);
layout_vert->addWidget(l_welcome);
layout_vert->addSpacing(30);
layout_vert->addLayout(v_1);
layout_vert->addSpacing(30);
layout_vert->addLayout(v_2);
this->setLayout(layout_vert);
}
To copy to clipboard, switch view to plain text mode
Thanks!!
Bookmarks