很感谢,刚学QT编程,很多都不懂。我能把代码贴上来你帮我看下吗。参数我不知道怎么设置。#ifndef CLOCK_H
#define CLOCK_H
#include <qvariant.h>
#include <qwidget.h>
#include<qpainter.h>
class QVBoxLayout; 
class QHBoxLayout; 
class QGridLayout; 
class Clock;
class Clock : public QWidget
{ 
    Q_OBJECT
public:
    Clock( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
    void PaintEvent(QPaintEvent*);
    ~Clock();
};
#endif // CLOCK_H
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/* 
 *  Constructs a Clock which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 */
Clock::Clock( QWidget* parent,  const char* name, WFlags WType_TopLevel )
    : QWidget( parent, name, WType_TopLevel )
{
    if ( !name )
    setName( "Clock" );
    resize( 588, 480 ); 
    setMaximumSize( QSize( 640, 480 ) );
    setBaseSize( QSize( 640, 480 ) );
    setCaption( tr( "Welcome to my university!" ) );
    setBackgroundOrigin( QWidget::ParentOrigin );
}
void Clock::PaintEvent(QPaintEvent*)
{
      QPainter painter;
      painter.setPen(red);
      painter.drawLine(0,0,50,50);
}
/*  
 *  Destroys the object and frees any allocated resources
 */
Clock::~Clock()
{
    // no need to delete child widgets, Qt does it all for us
}
#include"Clock.h"
#include<qapplication.h>
int main(int argc, char *argv[])
 {
      QApplication app(argc, argv);
      Clock pt;
      pt.resize(400, 150);
      pt.show();
      return app.exec();
}