/****************************************************************
**
** Qt教程一 - 3
**
****************************************************************/
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qvbox.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QVBox box;
box.resize( 200, 120 );
QPushButton quit( "Quit", &box );
quit.setFont( QFont( "Times", 18, QFont::Bold ) );
QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );
a.setMainWidget( &box );
box.show();
return a.exec();
}
**
** Qt教程一 - 3
**
****************************************************************/
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qvbox.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QVBox box;
box.resize( 200, 120 );
QPushButton quit( "Quit", &box );
quit.setFont( QFont( "Times", 18, QFont::Bold ) );
QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );
a.setMainWidget( &box );
box.show();
return a.exec();
}
在5.2.2中已经没有QVBox这个类了
QWidget *window = new QWidget;
QPushButton *button1 = new QPushButton("One");
QPushButton *button2 = new QPushButton("Two");
QPushButton *button3 = new QPushButton("Three");
QPushButton *button4 = new QPushButton("Four");
QPushButton *button5 = new QPushButton("Five");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->setLayout(layout);
window->show();
借鉴:
/****************************************************************
**
** Qt教程一 - 3
**
****************************************************************/
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qboxlayout.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QWidget window;
window.resize(200,120);
QVBoxLayout layout;
QPushButton quit( "Quit", &window );
quit.setFont( QFont( "Times", 18, QFont::Bold ) );
QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );
layout.addWidget(&quit);
window.setLayout(&layout);
window.show();
return a.exec();
}
**
** Qt教程一 - 3
**
****************************************************************/
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qboxlayout.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QWidget window;
window.resize(200,120);
QVBoxLayout layout;
QPushButton quit( "Quit", &window );
quit.setFont( QFont( "Times", 18, QFont::Bold ) );
QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );
layout.addWidget(&quit);
window.setLayout(&layout);
window.show();
return a.exec();
}