#include <QtGui/QApplication>
#include "mainwindow.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qlineedit.h>
#include <qstring.h>
class MyMainWindow : public QWidget
{
Q_OBJECT
public:
MyMainWindow();
public slots:
void CopyEdit(int);
private:
QPushButton *b1;
QPushButton *b2;
QPushButton *b3;
QLineEdit *ledit;
signals:
void valueChanged(int);
};
MyMainWindow::CopyEdit(int)
{
ledit->setText("this is a line of text!");
emit valueChanged(int);
connect(b2,SIGNAL(clicked()),ledit,SLOT(valueChanged(int)));
};
MyMainWindow::MyMainWindow()
{
this->setGeometry(300,300,400,400);
b1=new QPushButton("Click here to mark the tsxt",this);
b1->setGeometry(0,0,400,20);
b1->setFont(QFont("Times",10,QFont::Bold));
b2=new QPushButton("click here to unmark the text",this);
b2->setGeometry(0,25,400,20);
b2->setFont(QFont("Times",10,QFont::Bold));
b3=new QPushButton("click here to remove the text",this);
b3->setGeometry(0,50,400,20);
b3->setFont(QFont("Times",10,QFont::Bold));
ledit=new QLineEdit("this is a line of text!",this);
ledit->setGeometry(0,80,400,40);
connect(b1,SIGNAL(clicked()),ledit,SLOT(selectAll()));
//connect(b2,SIGNAL(clicked()),ledit,SLOT(CopyEdit()));
connect(b3,SIGNAL(clicked()),ledit,SLOT(clear()));
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyMainWindow w;
w.show();
return a.exec();
}
------解决方案--------------------
好像是说父类里面(QWidget?)是int CopyEdit(int)而子类里面(MyMainWindow)是void CopyEdit(int),这个两个函数不匹配,把MyMainWindow里面改成int CopyEdit(int)应该就好了。
------解决方案--------------------
------解决方案--------------------
没指定返回值.
------解决方案--------------------