#include "Textnum.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); Textnum tn; tn.connect(tn.gettext(),SIGNAL(tn.gettext().textChanged()),tn,SLOT(textslot()));//собственно тут //проблема ,строка с ошибкой, как исправить не знаю. tn.show(); return app.exec();} //========================================================#ifndef TEXTNUM_H#define TEXTNUM_H#include <QtGui>class Textnum : public QWidget { Q_OBJECTprivate: QLabel* lblText; QTextEdit* txtText; QLabel* lblNum; QTextEdit* txtNum;public: Textnum(QWidget* pwgt=0); bool Checknum(); QTextEdit gettext();public slots: void textslot();};#endif // TEXTNUM_H//===================================================#include "Textnum.h"Textnum::Textnum(QWidget *pwgt):QWidget(pwgt){ lblText= new QLabel("&Text and Num"); txtText= new QTextEdit(); lblText->setBuddy(txtText); lblNum = new QLabel("&Num"); txtNum=new QTextEdit("546"); lblNum->setBuddy(txtNum); QVBoxLayout* vbl1= new QVBoxLayout; vbl1->addWidget(lblText); vbl1->addWidget(txtText); QVBoxLayout* vbl2= new QVBoxLayout; vbl2->addWidget(lblNum); vbl2->addWidget(txtNum); QHBoxLayout* hblayout= new QHBoxLayout; hblayout->addLayout(vbl1); hblayout->addLayout(vbl2); setLayout(hblayout); }bool Textnum::Checknum(){ QString str; QPalette pal=txtNum->palette(); bool f=true; str=txtNum->toPlainText(); for(int i=0;i<str.length();++i){ if(str.at(i).isNumber()){ } else{ f=false; } } return f;}QTextEdit Textnum::gettext(){ return txtNum;}Textnum::textslot(){ if(Checknum()){ QMessageBox::information(0,"this","num"); } else{ QMessageBox::information(0,"this","notnum"); }}
tn.connect(tn.gettext(), SIGNAL(textChanged()), tn, SLOT(textslot()));
tn.connect(tn.gettext(),SIGNAL(tn.gettext().textChanged()),tn,SLOT(textslot()))
connect(this->lineEdit1,SIGNAL(textChanged()),this,SLOT(textslot()))
connect(txtNum,SIGNAL(textChanged()),SLOT(textslot()));