首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

QT有关问题

2012-04-03 
QT问题我使用qtdesigner生成一个对话框。通过uic-ogetmp3.hgetmp3.uiuic-igetmp3.h-ogetmp3.cppgetmp3.uimo

QT问题
我使用qt   designer生成一个对话框。通过
uic   -o   getmp3.h   getmp3.ui
uic   -i   getmp3.h   -o   getmp3.cpp   getmp3.ui
moc   getmp3.h   -o   moc_getmp3.cpp
做成相应的文件,添加到一个新工程,main函数如下:
#include   "getmp3.h "
#include   <qapplication.h>
int   main(int   argc,   char   **argv)
{
        QApplication   app(argc,   argv,   "Getmp3 ");  
        Getmp3   *form1=new   Getmp3();
        form1-> show();
        app.setMainWidget(form1);
        return(app.exec());
}
现在想实现一个按钮的响应函数,在getmp3.cpp中实现,但是只要添加#include <afx.h> 和CFindFile类就不能链接,就算我新建一个自定义的类,也同样不能链接。QT到底如何使用啊。。。。

[解决办法]
connect(,SIGNAL(),SLOT());
[解决办法]
//youClass.h

#include <QWidget>
#include "ui_getmp3.h "

class youClass : public QWidget, public Ui::getmp3
{
Q_OBJECT
public:
youClass( QWidget *parent = 0 );
private slots:
void youEvent();
}

//youClass.cpp
#include <QtGui>
#include "youClass.h "

youClass::youClass( QWidget *parent )
:QWidget(parent)
{
setupUi(this);
connect( youButtonName, SIGNAL(clicked()), this, SLOT(youEvent()) );
// youButton have been buided in the getmp3.ui
}

//main.cpp
#include <QApplication>
#include "youClass.h "
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
youClass *form1=new youClass();
form1-> show();
app.setMainWidget(form1);
// setMainwidget not exit in QT4 (you can del this line in QT4)
return app.exec();
}

$qmake -project
$qmake
$make

热点排行