class LoadBase : public QDialog{ Q_OBJECTpublic: LoadBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~LoadBase(); QLineEdit* File; QProgressBar* progress; QPushButton* buttonLoadFile; QPushButton* buttonCancel;protected: QHBoxLayout* layout3; QSpacerItem* spacer_butt;protected slots: virtual void languageChange();};
LoadBase::LoadBase( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ){ //.....}
#include "load.h"#include <qvariant.h>#include <qsplitter.h>#include <qlineedit.h>#include <qprogressbar.h>#include <qpushbutton.h>#include <qlayout.h>#include <qtooltip.h>#include <qwhatsthis.h>class Load : public LoadBase{public: Load( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );public slots:// void CloseForm(); void loadFile();};Load::Load( QWidget* parent, const char* name, bool modal, WFlags fl ) : LoadBase ( parent, name, modal, fl ){ connect( buttonLoadFile, SIGNAL(clicked()), this, SLOT(loadFile()) );};void Load::loadFile(){ QMessageBox::information( 0, "Info", "Load file", 0, 0, 0 ); return;};
public slots: virtual void loadFile();
/****************************************************************************** Form interface generated from reading ui file 'load.ui'**** Created: Птн Авг 5 15:02:41 2005** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.4 edited Nov 24 2003 $)**** WARNING! All changes made in this file will be lost!****************************************************************************/#ifndef LOADBASE_H#define LOADBASE_H#include <qvariant.h>#include <qdialog.h>class QVBoxLayout;class QHBoxLayout;class QGridLayout;class QSpacerItem;class QGroupBox;class QProgressBar;class QLineEdit;class QPushButton;class LoadBase : public QDialog{ Q_OBJECTpublic: LoadBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~LoadBase(); QGroupBox* groupB; QProgressBar* progress; QLineEdit* File; QPushButton* buttonLoadFile; QPushButton* buttonCancel;// виртульные функции слотыpublic slots: virtual void loadFile(); virtual void closeForm();// ^^виртульные функции слоты^^protected: QGridLayout* LoadBaseLayout; QGridLayout* groupBLayout; QVBoxLayout* layout4;protected slots: virtual void languageChange();};#endif // LOADBASE_H
/****************************************************************************** Form implementation generated from reading ui file 'load.ui'**** Created: Птн Авг 5 15:02:48 2005** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.4 edited Nov 24 2003 $)**** WARNING! All changes made in this file will be lost!****************************************************************************/#include "load.h"#include <qvariant.h>#include <qpushbutton.h>#include <qgroupbox.h>#include <qprogressbar.h>#include <qlineedit.h>#include <qlayout.h>#include <qtooltip.h>#include <qwhatsthis.h>/* * Constructs a LoadBase as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */LoadBase::LoadBase( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ){ if ( !name ) setName( "LoadBase" ); setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth() ) ); setMinimumSize( QSize( 360, 120 ) ); setMaximumSize( QSize( 800, 120 ) ); setBaseSize( QSize( 360, 120 ) ); setSizeGripEnabled( TRUE ); LoadBaseLayout = new QGridLayout( this, 1, 1, 11, 6, "LoadBaseLayout"); groupB = new QGroupBox( this, "groupB" ); groupB->setMinimumSize( QSize( 260, 80 ) ); groupB->setMaximumSize( QSize( 1024, 80 ) ); groupB->setLineWidth( 0 ); groupB->setColumnLayout(0, Qt::Vertical ); groupB->layout()->setSpacing( 6 ); groupB->layout()->setMargin( 11 ); groupBLayout = new QGridLayout( groupB->layout() ); groupBLayout->setAlignment( Qt::AlignTop ); progress = new QProgressBar( groupB, "progress" ); groupBLayout->addWidget( progress, 1, 0 ); File = new QLineEdit( groupB, "File" ); File->setEnabled( TRUE ); File->setMouseTracking( TRUE ); File->setFocusPolicy( QLineEdit::NoFocus ); groupBLayout->addWidget( File, 0, 0 ); LoadBaseLayout->addWidget( groupB, 0, 0 ); layout4 = new QVBoxLayout( 0, 0, 6, "layout4"); buttonLoadFile = new QPushButton( this, "buttonLoadFile" ); buttonLoadFile->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, buttonLoadFile->sizePolicy().hasHeightForWidth() ) ); buttonLoadFile->setMinimumSize( QSize( 70, 25 ) ); buttonLoadFile->setMaximumSize( QSize( 70, 30 ) ); layout4->addWidget( buttonLoadFile ); buttonCancel = new QPushButton( this, "buttonCancel" ); buttonCancel->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, buttonCancel->sizePolicy().hasHeightForWidth() ) ); buttonCancel->setMinimumSize( QSize( 70, 30 ) ); buttonCancel->setMaximumSize( QSize( 70, 30 ) ); buttonCancel->setAutoDefault( TRUE ); layout4->addWidget( buttonCancel ); LoadBaseLayout->addLayout( layout4, 0, 1 ); languageChange(); resize( QSize(360, 120).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished );}/* * Destroys the object and frees any allocated resources */LoadBase::~LoadBase(){ // no need to delete child widgets, Qt does it all for us}/* * Sets the strings of the subwidgets using the current * language. */void LoadBase::languageChange(){ setCaption( tr( "Load data from file" ) ); groupB->setTitle( QString::null ); buttonLoadFile->setText( trUtf8( "\xd0\x97\xd0\xb0\xd0\xb3\xd1\x80\xd1\x83\xd0\xb7\xd0\xba\xd0\xb0" ) ); buttonCancel->setText( tr( "&Cancel" ) ); buttonCancel->setAccel( QKeySequence( QString::null ) );}
#ifndef BEGFORM_H#define BEGFORM_H#include <qvariant.h>#include <qsplitter.h>#include <qlineedit.h>#include <qprogressbar.h>#include <qpushbutton.h>#include <qlayout.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qfiledialog.h>#include "load.h"class Load : public LoadBase{public: Load( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); char load_fl;public slots: void closeForm(); void loadFile();};Load::Load( QWidget* parent, const char* name, bool modal, WFlags fl ) : LoadBase ( parent, name, modal, fl ) { load_fl=0; connect( buttonLoadFile, SIGNAL(clicked()), this, SLOT(loadFile()) ); connect( buttonCancel, SIGNAL(clicked()), this, SLOT(closeForm()) );};void Load::loadFile(){ if (load_fl==0) { QString fn = QFileDialog::getOpenFileName( QString::null, "*.dat", this ); if ( !fn.isEmpty() ) { File->setText(fn); buttonLoadFile->setText(QString::fromLocal8Bit("Прервать")); load_fl=1;// load( fn ); } } else { buttonLoadFile->setText(QString::fromLocal8Bit("Загрузка")); load_fl=0; } return;};void Load::closeForm(){ emit close(); return;};#endif
/****************************************************************************** $Id: qt/main.cpp 3.3.4 edited Jun 21 2004 $**** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.**** This file is part of an example program for Qt. This example** program may be used, distributed and modified without limitation.*******************************************************************************/#include <qapplication.h>#include <qtable.h>#include <qimage.h>#include <qfile.h>#include <qpixmap.h>#include <qstringlist.h>#include <qmessagebox.h>#include <qstring.h>#include <qprogressbar.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include "begform.h"// The program starts here.int main( int argc, char **argv ){ QApplication app( argc, argv ); Load MainW; MainW.show(); app.setMainWidget( &MainW ); return app.exec();}