Подскажите пожалуйста ато мозг устал...
Как в виджите QLineEdit проверить что есть информация не нуливая в пределах одной области видемости, что бы потом можно было дать разришение на нажатие кнопок?
Спасибо за внимание!
void FormsAddEditSp::fSkAdd(){
setMinimumSize(600, 380);
setMaximumSize(600, 380);
grBox = new QGroupBox(tr("Здесь вы можите добавить запись в справочник корреспандентов:"), this);
nameL = new QLabel(tr("Наименование: "), this);
descriptionL = new QLabel(tr("Полное имя: "), this);
accountL = new QLabel(tr("Расчётный счёт: "), this);
mfoL = new QLabel(tr("МФО: "), this);
kodokpoL = new QLabel(tr("Код ОКПО: "), this);
addressL = new QLabel(tr("Адрес: "), this);
inmpL = new QLabel(tr("Регестрационный номер: "), this);
nsvdL = new QLabel(tr("Номер свидетельства: "), this);
phoneL = new QLabel(tr("Телефон: "), this);
nameE = new QLineEdit(this);
descriptionE = new QLineEdit(this);
accountE = new QLineEdit(this);
mfoE = new QLineEdit(this);
kodokpoE = new QLineEdit(this);
addressE = new QLineEdit(this);
inmpE = new QLineEdit(this);
nsvdE = new QLineEdit(this);
phoneE = new QLineEdit(this);
//Валидность
nameE->setMaxLength(30);
descriptionE->setMaxLength(255);
addressE->setMaxLength(50);
QRegExp evAccount(tr("[0-9]{14}"));
accountE->setValidator(new QRegExpValidator(evAccount, this));
QRegExp evKodokpo(tr("[0-9]{10}"));
kodokpoE->setValidator(new QRegExpValidator(evKodokpo, this));
QRegExp evMfoInmpNsvd(tr("[0-9]{12}"));
mfoE->setValidator(new QRegExpValidator(evMfoInmpNsvd, this));
inmpE->setValidator(new QRegExpValidator(evMfoInmpNsvd, this));
nsvdE->setValidator(new QRegExpValidator(evMfoInmpNsvd, this));
QRegExp evPhone(tr("[0-9+() -]{36}"));
phoneE->setValidator(new QRegExpValidator(evPhone, this));
//end
btnBox = new QDialogButtonBox(Qt::Horizontal, this);
btnBox->addButton(tr("Записать"), QDialogButtonBox::AcceptRole);
btnBox->addButton(tr("Отмена"), QDialogButtonBox::RejectRole);
gridLay = new QGridLayout(this);
gridLay->setMargin(15);
gridLay->setSpacing(10);
gridLay->addWidget(nameL, 1, 0);
...
бля-бля-бля
....
gridLay->addWidget(btnBox, 10, 1, 1, 2);
gridLay->setColumnStretch(1, 2);
gridLay->setRowStretch(10, 2);
grBox->move(10, 10);
grBox->resize(580, 360);
grBox->setLayout(gridLay);
connect(btnBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(btnBox, SIGNAL(rejected()), this, SLOT(reject()));
}
bool FormsAddEditSp::buttonFSkAdd(){
if(exec() == QDialog::Accepted){
finList << nameE->text() << descriptionE->text() << accountE->text() << mfoE->text() << addressE->text() << phoneE->text() << kodokpoE->text() <<inmpE->text() << nsvdE->text();
DbConnect *fdb = new DbConnect(this);
fdb->insertDT(tr("firm"), tr("name,description,account,mfo,address,phone,kod_okpo,inmp,nsvd"), finList);
delete fdb;
QMessageBox::about(this, tr("Внимание!"), tr("Всё работает!!!"));
return true;
}
return false;
}
#include <QtGui>
int main(int argc, char **argv){
QApplication app(argc, argv);
QDialog dia;
QLineEdit ed;
QHBoxLayout lay;
QPushButton btn("OK");
btn.setDisabled(true);
if() //Вставить услове которое разблокирует кнопку ????????
btn.setDisabled(false);
lay.addWidget(&ed, 1);
lay.addWidget(&btn);
dia.setLayout(&lay);
dia.resize(250, 40);
dia.show();
return app.exec();
}
#ifndef BLOCKBUTTON_H
#define BLOCKBUTTON_H
#include <QtGui>
class BlockButton : public QWidget
{
Q_OBJECT
public:
BlockButton(QWidget *parent = 0);
~BlockButton(){};
private:
QPushButton *button;
QLineEdit *line;
QVBoxLayout *vLay;
private slots:
void s_blockButton(QString);
};
#endif // BLOCKBUTTON_H
#include "blockbutton.h"
BlockButton::BlockButton(QWidget *parent)
: QWidget(parent)
{
vLay = new QVBoxLayout;
button = new QPushButton("Next");
button->setDisabled(true);
line= new QLineEdit;
connect(line, SIGNAL(textChanged(QString)),
this, SLOT(s_blockButton(QString)));
vLay->addWidget(line);
vLay->addWidget(button);
setLayout(vLay);
}
void BlockButton::s_blockButton(QString s)
{
if(s.isEmpty())
button->setDisabled(true);
else
button->setDisabled(false);
}
void BlockButton::s_blockButton()
{
bool first = lineOne->text().isEmpty();
bool second = lineTwo->text().isEmpty();
bool third = lineThree->text().isEmpty();
if(first || second || third)
button->setDisabled(true);
else
button->setDisabled(false);
}