From bd0f3345a938b35ce6a12f6150373b0955b8dd12 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Jul 2011 15:24:15 -0500 Subject: Add Qt3 development HEAD version --- doc/html/extension-dialog-example.html | 168 +++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 doc/html/extension-dialog-example.html (limited to 'doc/html/extension-dialog-example.html') diff --git a/doc/html/extension-dialog-example.html b/doc/html/extension-dialog-example.html new file mode 100644 index 0000000..e367b8c --- /dev/null +++ b/doc/html/extension-dialog-example.html @@ -0,0 +1,168 @@ + + + + + +An Extension Dialog Example + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

An Extension Dialog Example

+ + + +

+

This example demonstrates how to create an extension dialog. +

Essentially all that is necessary is to create a standard dialog +and then create a QWidget form to be used as the extension. See +the article in Qt + Quarterly issue #3. +


+

Project file: +

TEMPLATE        = app
+LANGUAGE        = C++
+
+CONFIG          += qt warn_on release
+
+REQUIRES        = full-config nocrosscompiler
+
+SOURCES         += main.cpp
+FORMS           = mainform.ui \
+                  dialogform.ui \
+                  extension.ui
+DBFILE          = extension.db
+
+ +


+


+

Implementation: +

/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions use Qt Designer which will
+** update this file, preserving your code. Create an init() function in place
+** of a constructor, and a destroy() function in place of a destructor.
+*****************************************************************************/
+#include "dialogform.h"
+#include "extension.h"
+#include <qapplication.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
+
+void MainForm::init()
+{
+    sessions = FALSE;
+    logging = FALSE;
+    log_filename = QString::null;
+    log_errors = TRUE;
+    log_actions = TRUE;
+}
+
+void MainForm::optionsDlg()
+{
+    DialogForm *dlg = new DialogForm( this, "dialog", TRUE );
+    Extension *ext = (Extension*)dlg->extension()->qt_cast( "Extension" );
+    if ( !ext )
+        return;
+    dlg->sessionsCheckBox->setChecked( sessions );
+    dlg->loggingCheckBox->setChecked( logging );
+    ext->logfileLineEdit->setText( log_filename );
+    ext->logErrorsCheckBox->setChecked( log_errors );
+
+    if ( dlg->exec() ) {
+        sessions = dlg->sessionsCheckBox->isChecked();
+        logging = dlg->loggingCheckBox->isChecked();
+        log_filename = ext->logfileLineEdit->text();
+        log_errors = ext->logErrorsCheckBox->isChecked();
+    }
+}
+
+
+void MainForm::quit()
+{
+    QApplication::exit( 0 );
+}
+
+ +
/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions use Qt Designer which will
+** update this file, preserving your code. Create an init() function in place
+** of a constructor, and a destroy() function in place of a destructor.
+*****************************************************************************/
+
+void DialogForm::init()
+{
+    extensionShown = FALSE;
+    setExtension( new Extension( this ) );
+    setOrientation( Vertical );
+}
+
+
+void DialogForm::toggleDetails()
+{
+    extensionShown = !extensionShown;
+    showExtension( extensionShown );
+    QString text = tr( "&Details " );
+    text += QString( extensionShown ? "<<<" : ">>>" );
+    detailsPushButton->setText( text );
+}
+
+ +
/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions use Qt Designer which will
+** update this file, preserving your code. Create an init() function in place
+** of a constructor, and a destroy() function in place of a destructor.
+*****************************************************************************/
+
+ +


+

Main: +

#include <qapplication.h>
+#include "mainform.h"
+
+int main( int argc, char ** argv )
+{
+    QApplication a( argc, argv );
+    MainForm *w = new MainForm;
+    w->show();
+    a.connect( &a, SIGNAL( lastWindowClosed() ), w, SLOT( quit() ) );
+    return a.exec();
+}
+
+ +

See also Step-by-step Examples. + + +


+ +
Copyright © 2007 +TrolltechTrademarks +
Qt 3.3.8
+
+ -- cgit v1.2.3