Dynamic Dialogs

Dynamic dialogs are dialogs that are created from a Qt Designer .ui file at runtime. Dynamic dialogs are not converted into C++ code by uic. Instead, the .ui file is loaded at run-time using the QWidgetFactory class, in the following way:

QDialog *sortDialog = (QDialog *)
 QWidgetFactory::create("sortdialog.ui");

We can access the form's child widgets using QObject::child():

QComboBox *primaryColumnCombo = (QComboBox *)
 sortDialog->child("primaryColumnCombo", "QComboBox");

The child() function returns a null pointer if the dialog has no child that matches the given name and type.

The QWidgetFactory class is located in a separate library. To use QWidgetFactory from a Qt application, we must add this line to the application's .pro file:

LIBS += -lqui

This syntax works on all platforms, even though it has a definite Unix flavor.

Dynamic dialogs make it possible to change the layout of the form without recompiling the application. For a complete example of an application that uses a dynamic dialog, see the "Subclassing and Dynamic Dialogs" chapter in the Qt Designer manual.

Part I: Basic Qt

Getting Started

Creating Dialogs

Creating Main Windows

Implementing Application Functionality

Creating Custom Widgets

Part II: Intermediate Qt

Layout Management

Event Processing

2D and 3D Graphics

Drag and Drop

Input/Output

Container Classes

Databases

Networking

XML

Internationalization

Providing Online Help

Multithreading

Platform-Specific Features



C++ GUI Programming with Qt 3
C++ GUI Programming with Qt 3
ISBN: 0131240722
EAN: 2147483647
Year: 2006
Pages: 140

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net