//main.cpp
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include "slot.h"
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton quit( "mp3play", 0 );
quit.resize( 175, 130 );
quit.setFont( QFont( "Times", 18, QFont::Bold ) );
MP3play b;
b.addArgument("sh");
b.addArgument("/1");
QObject::connect( &quit, SIGNAL(clicked()), &b, SLOT(mySlot()) );
a.setMainWidget( &quit );
quit.show();
return a.exec();
}
//slot.h
#include<qprocess.h>
class MP3play : QProcess
{
Q_OBJECT;
public:
MP3play();
public slots:
void myslot();
signals:
};
//slot.c
#include<qporcess.h>
#include<qwidget.h>
#include "slot.h"
void MP3play::myslot()
{
start();
}
//error
[root@host test4]# make
g++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I. -I/usr/lib/qt-3.1/include -o qt.o qt.cpp
qt.cpp: In function `int main(int, char**)':
qt.cpp:15: `QObject' is an inaccessible base of `MP3play'
make: *** [qt.o] Error 1
[ 此贴被XChinux在2006-06-07 00:36重新编辑 ]