seerofsorrow
16th November 2017, 22:16
<code>
#include "header2.h"
#include "ui_gui2.h"
#include <QPushButton>
#include <QSignalMapper>
Classy2::Classy2(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Classy2)
{
ui->setupUi(this);
}
Classy2::~Classy2()
{
delete ui;
}
//Actions for Templates
void Classy2::on_chronologyPushButton_pressed()
{
QFont font;
font.setPointSize(10);
font.setBold(true);
QLabel *numberLabel=new QLabel;
QTextEdit *chronoEdit=new QTextEdit;
QGridLayout *chronologyGridLayout=new QGridLayout;
QSignalMapper *signalMapper=new QSignalMapper(ui->chronologyWidget);
numberLabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
numberLabel->setAlignment(Qt::AlignVCenter);
numberLabel->setFont(font);
numberLabel->setText("3.");
chronoEdit->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
chronoEdit->setAlignment(Qt::AlignVCenter);
chronoEdit->setFixedWidth(365);
chronoEdit->setFixedHeight(30);
ui->chronologyWidget->setMinimumSize(461,200);
connect(chronologyPushButton,SIGNAL(clicked()),sig nalMapper,SLOT(move()));
signalMapper->setMapping(chronologyPushButton,chronologyGridLayo ut);
chronologyGridLayout->addWidget(chronologyPushButton,4,0,Qt::AlignVCente r);
ui->chronologyGridLayout->addWidget(chronoEdit,2,1,Qt::AlignVCenter);
ui->chronologyGridLayout->addWidget(numberLabel,2,0,Qt::AlignVCenter);
ui->chronologyWidget->setLayout(ui->chronologyGridLayout);
ui->chronologyWidget->resize(401,91);
}
</code>
I have a qpushbutton inside of a qgridlayout inside of a qwidget. I am attempting to get the qpushbutton to move down one row once it's been clicked and a new label and qtextedit will be placed where the qpushbutton once was. however I ca't get the qpushbutton to move downwards. Can anybody tell me how to get the pushbutton tomove from 2,0 to 3,0 (or 4,0 from my code.) thank you
#include "header2.h"
#include "ui_gui2.h"
#include <QPushButton>
#include <QSignalMapper>
Classy2::Classy2(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Classy2)
{
ui->setupUi(this);
}
Classy2::~Classy2()
{
delete ui;
}
//Actions for Templates
void Classy2::on_chronologyPushButton_pressed()
{
QFont font;
font.setPointSize(10);
font.setBold(true);
QLabel *numberLabel=new QLabel;
QTextEdit *chronoEdit=new QTextEdit;
QGridLayout *chronologyGridLayout=new QGridLayout;
QSignalMapper *signalMapper=new QSignalMapper(ui->chronologyWidget);
numberLabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
numberLabel->setAlignment(Qt::AlignVCenter);
numberLabel->setFont(font);
numberLabel->setText("3.");
chronoEdit->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
chronoEdit->setAlignment(Qt::AlignVCenter);
chronoEdit->setFixedWidth(365);
chronoEdit->setFixedHeight(30);
ui->chronologyWidget->setMinimumSize(461,200);
connect(chronologyPushButton,SIGNAL(clicked()),sig nalMapper,SLOT(move()));
signalMapper->setMapping(chronologyPushButton,chronologyGridLayo ut);
chronologyGridLayout->addWidget(chronologyPushButton,4,0,Qt::AlignVCente r);
ui->chronologyGridLayout->addWidget(chronoEdit,2,1,Qt::AlignVCenter);
ui->chronologyGridLayout->addWidget(numberLabel,2,0,Qt::AlignVCenter);
ui->chronologyWidget->setLayout(ui->chronologyGridLayout);
ui->chronologyWidget->resize(401,91);
}
</code>
I have a qpushbutton inside of a qgridlayout inside of a qwidget. I am attempting to get the qpushbutton to move down one row once it's been clicked and a new label and qtextedit will be placed where the qpushbutton once was. however I ca't get the qpushbutton to move downwards. Can anybody tell me how to get the pushbutton tomove from 2,0 to 3,0 (or 4,0 from my code.) thank you