如下是我的代码,清大牛给看看怎么回事,只是收到了焦点但没有光标阿(AddEdt())
#include "example.h"
#include <qpushbutton.h>
#include <QMessageBox>
ExampleBase::ExampleBase( QWidget *parent, Qt::WFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
ExampleBase::~ExampleBase()
{
}
/*
* Constructs a Example which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
Example::Example( QWidget *parent, Qt::WFlags f )
: ExampleBase( parent, f )
{
EdtNum1->setText("100");
EdtNum1->setFocus();
connect(quit, SIGNAL(clicked()), this, SLOT(goodBye()));
connect(BtnAdd, SIGNAL(clicked()), this, SLOT(AddEdt()));
connect(EdtNum1, SIGNAL(returnPressed()), this, SLOT(ShowMsg()));
}
/*
* Destroys the object and frees any allocated resources
*/
Example::~Example()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* A simple slot... not very interesting.
*/
void Example::goodBye()
{
close();
}
void Example::AddEdt()
{
QString x, y;
int z;
x = EdtNum1->text();
y = EdtNum2->text();
z = x.toInt() + y.toInt();
EdtResult->setText(QString::number(z));
}
void Example::ShowMsg()
{
QMessageBox* msg = new QMessageBox(QMessageBox::Information, "Test", "That's Right!");
msg->exec();
}