QVBoxLayout 不是从 QWidget 继承的
新代码:
/****************************************************************
**
** Qt教程一 - 5
**
****************************************************************/
#include <qapplication.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qlcdnumber.h>
#include <qfont.h>
#include <QVBoxLayout>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QWidget window;
QPushButton *quit = new QPushButton( "Quit", &window );
quit->setFont( QFont( "Times", 18, QFont::Bold ) );
QObject::connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
QLCDNumber *lcd = new QLCDNumber( 2, &window );
QSlider * slider = new QSlider( Qt::Horizontal, &window );
slider->setRange( 0, 99 );
slider->setValue( 0 );
QObject::connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );
QVBoxLayout layout;
layout.addWidget(quit);
layout.addWidget(lcd);
layout.addWidget(slider);
window.setLayout(&layout);
window.show();
return a.exec();
}
阅读(619) | 评论(0) | 转发(0) |