#include "mainwindow.h"
#include <QObject>
#include <QtGui>
#include <QIntValidator>
#include <QWidget>
MainWindow
::MainWindow(QWidget *parent
) :{
grid->addWidget(input(), 0, 0);
setLayout(grid);
setWindowTitle(tr("QLineEdit example"));
setMinimumSize(500, 400);
}
{
QLabel *fwerl
= new QLabel(tr
("<font>Insert your values:</font>"));
QFormLayout *formLayout = new QFormLayout;
formLayout->addRow(fwerl);
formLayout->addRow(tr("1st value:"), in1);
formLayout->addRow(tr("2nd value:"), in2);
formLayout->addRow(tr("3rd value:"), in3);
groupBox->setLayout(formLayout);
connect(in1,
SIGNAL(textChanged
(QString)),
this,
SLOT(in1TextChanged
()));
connect(in2,
SIGNAL(textChanged
(QString)),
this,
SLOT(in2TextChanged
()));
in1->setValidator(validator);
in2->setValidator(validator);
in3->setValidator(validator);
return groupBox;
}
void MainWindow::in1TextChanged()
{
if(in1->text()=="")
{
in2->setDisabled(1);
}
else
{
in2->setEnabled(1);
}
}
void MainWindow::in2TextChanged()
{
if(in2->text()=="")
{
in3->setDisabled(1);
}
else
{
in3->setEnabled(1);
}
}
MainWindow::~MainWindow()
{
delete mainWindow;
}
#include "mainwindow.h"
#include <QObject>
#include <QtGui>
#include <QIntValidator>
#include <QWidget>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QGridLayout *grid = new QGridLayout;
grid->addWidget(input(), 0, 0);
setLayout(grid);
setWindowTitle(tr("QLineEdit example"));
setMinimumSize(500, 400);
}
QGroupBox *MainWindow::input()
{
QGroupBox *groupBox = new QGroupBox(tr("Input"));
QLabel *fwerl = new QLabel(tr("<font>Insert your values:</font>"));
in1 = new QLineEdit;
in2 = new QLineEdit;
in3 = new QLineEdit;
QFormLayout *formLayout = new QFormLayout;
formLayout->addRow(fwerl);
formLayout->addRow(tr("1st value:"), in1);
formLayout->addRow(tr("2nd value:"), in2);
formLayout->addRow(tr("3rd value:"), in3);
groupBox->setLayout(formLayout);
connect(in1,SIGNAL(textChanged(QString)),this,SLOT(in1TextChanged()));
connect(in2,SIGNAL(textChanged(QString)),this,SLOT(in2TextChanged()));
QValidator *validator = new QDoubleValidator(0.0, 1.0, 10, in1);
in1->setValidator(validator);
in2->setValidator(validator);
in3->setValidator(validator);
return groupBox;
}
void MainWindow::in1TextChanged()
{
if(in1->text()=="")
{
in2->setDisabled(1);
}
else
{
in2->setEnabled(1);
}
}
void MainWindow::in2TextChanged()
{
if(in2->text()=="")
{
in3->setDisabled(1);
}
else
{
in3->setEnabled(1);
}
}
MainWindow::~MainWindow()
{
delete mainWindow;
}
To copy to clipboard, switch view to plain text mode
Bookmarks