关于Qt的moc的使用

freekingdong 2009-08-05 04:17:22
下面是我写的程序]代码,但不知道如何用moc,请指教
/******************************************************************************************************************
**File: doublevalidator.cpp
**Author: Freeking
**Created: August 1st
**Description: 对于doublevalidator类的应用
********************************************************************************************************************/
#include <qapplication.h>
#include <qwidget.h>
#include <qlineedit.h>
#include <qvalidator.h>
#include <qmessagebox.h>
class MyMainWindow : public QWidget
{
Q_OBJECT
public:
MyMainWindow();
private:
QDoubleValidator *dvalid;
QLineEdit *edit;
public slots:
void slotReturnPressed();
}
/*Define the slot which will be called when the
user has entered a valid strig and then presses enter*/
void MyMainWindow::slotReturnPressed()
{
QMessageBox *mbox = new QMessageBox( "Validator Results", "if you see this message, the string you enter in the
QLineEdit object is Acceptable.", QMessageBox::Information, QMessageBox::Ok,0, 0 );
mbox->show();
}
~

MyMainWindow::MyMainWindow()
{
setGeometry( 100, 100, 200, 50 );
dvalid = new QDoubleValidator( 0.0, 10.0, 1, this );

edit = new QLineEdit( this );
edit->setGeometry( 10, 10, 180, 30 );
edit->setValidator( dvalid );

connect( edit, SIGNAL( returnPressed() ), this, SLOT( slotReturnPressed() ) );
}

int main( int argc, char** argv )
{
QApplication a(argc, argv);
MyMainWindow w;
a.setMainWidget( &w );
w.show();
return a.exec();
}
...全文
662 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
freekingdong 2009-08-06
  • 打赏
  • 举报
回复
跟minigui有关系吗?
mississipii 2009-08-06
  • 打赏
  • 举报
回复
moc好像是编译器产生的文件吧?在make时自动生成的文件
hezhiyonging 2009-08-05
  • 打赏
  • 举报
回复
在用minigui!

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧