1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <qvaluelist.h>
#include "st.h"
#include <iostream>
TApp::TApp( int argc, char** argv ) :
QApplication( argc, argv ), b1(0), b2(0)
{
}
TApp::~TApp()
{}
void TApp::clicked1()
{
if ( b2->isVisible() ) {
b2->hide();
}
else {
b2->show();
}
}
void TApp::clicked2()
{
if ( b1->isVisible() ) {
b1->hide();
}
else {
b1->show();
}
}
//------------------------------------------------------------------------------
//
int main( int argc, char** argv )
{
TApp app( argc, argv );
QSizePolicy maxsp( QSizePolicy::Maximum, QSizePolicy::Maximum );
QMainWindow* mw = new QMainWindow;
QWidget* cw = new QWidget( mw );
{
QHBoxLayout* lcw = new QHBoxLayout( cw );
QSplitter* spl = new QSplitter( cw );
{
spl->setOrientation( Qt::Vertical );
{
app.b1 = new QPushButton( spl );
app.b1->setText( "button 1" );
app.b2 = new QPushButton( spl);
app.b2->setText( "button 2" );
QObject::connect( app.b1, SIGNAL(clicked()),
&app, SLOT(clicked1()) );
QObject::connect( app.b2, SIGNAL(clicked()),
&app, SLOT(clicked2()) );
}
QValueList<int> vl;
vl.append( 10 );
vl.append( 20 );
spl->setSizes( vl );
}
lcw->addWidget( spl );
QPushButton* but = new QPushButton( cw );
but->setText( "overview" );
but->setSizePolicy( maxsp );
lcw->addWidget( but );
}
mw->statusBar();
mw->setCentralWidget( cw );
app.setMainWidget( mw );
mw->show();
int r = app.exec();
return r;
}
|