void classISQL::OpenSQL() { QMultiLineEdit *txt; if ( pTabBar->currentTab() == 0 ) { pSliderRecentSQL->setValue( pSliderRecentSQL->maxValue() ); txt = txtSQL; } else txt = txtResults; // LET USER PICK A FILE QString qsFile = QFileDialog::getOpenFileName(); if ( qsFile.isNull() ) return; // TRY TO LOAD THE FILE QFile hFile( qsFile ); if ( !hFile.open( IO_ReadOnly ) ) return; txt->setAutoUpdate( FALSE ); txt->clear(); QTextStream t( &hFile ); while ( !t.eof() ) { QString s = t.readLine(); txt->append( s ); } hFile.close(); txt->setAutoUpdate( TRUE ); txt->repaint(); if ( pTabBar->currentTab() == 0 ) qsSQLFileName = qsFile; else qsResultsFileName = qsFile; setTextType( 0 ); }
int main(int argc, char **argv) { QApplication app(argc, argv); QWidget *messageWindow = new QWidget(); app.setMainWidget(messageWindow); messageWindow->setFixedSize(220, 150); QMultiLineEdit *messages = new QMultiLineEdit(messageWindow); messages->setGeometry(10, 10, 200, 100); QPushButton *clear = new QPushButton("Clear", messageWindow); clear->setGeometry(10, 120, 95, 20); QPushButton *hide = new QPushButton("Hide", messageWindow); hide->setGeometry(115, 120, 95, 20); messageWindow->setCaption("einfacher Dialog"); messages->setReadOnly(true); messages->append("Initialisierung abgeschlossen\n"); messageWindow->show(); return app.exec(); }