Generic dialog box class.
#include <QtxDialog.h>

Data Structures | |
| class | Area |
| Area containing dialog box buttons. More... | |
| class | Border |
| Special label used as border widget (separator between main frame and button frame). More... | |
Public Types | |
| enum | PlacePolicy { Position, Expand, Uniform } |
Buttons alignment type. More... | |
| enum | ButtonArea { TopArea, BottomArea, LeftArea, RightArea } |
Buttons area. More... | |
| enum | ButtonPosition { Left, Right, Center, Top = Left, Bottom = Right } |
Button position. More... | |
| enum | ButtonFlags { None = 0x00000000, OK = 0x00000001, Apply = 0x00000002, Cancel = 0x00000004, Yes = 0x00000008, No = 0x00000010, Close = 0x00000020, Help = 0x00000040, OKCancel = OK | Cancel, YesNo = Yes | No, Standard = OK | Cancel | Help, All = Standard | YesNo | Apply | Close } |
Button ID flags. More... | |
| enum | DialogFlags { Accept = 0x000001, Reject = 0x000002, AlignOnce = 0x000004, SetFocus = 0x000008 } |
Dialog box flags. More... | |
Public Slots | |
| void | update () |
| Update dialog box. | |
| virtual void | setVisible (bool) |
| Show/hide dialog box, set keyboard focus to the dialog. | |
Signals | |
| void | dlgButton (int) |
| Emitted when the user button is clicked. | |
| void | dlgParamChanged () |
| This signal can be used in successor classes to signalize about some dialog parameter changing. | |
| void | dlgHelp () |
| Emitted when the "Help" button is clicked. | |
| void | dlgApply () |
| Emitted when the "Apply" button is clicked. | |
| void | dlgOk () |
| Emitted when the "OK" button is clicked. | |
| void | dlgNo () |
| Emitted when the "No" button is clicked. | |
| void | dlgYes () |
| Emitted when the "Yes" button is clicked. | |
| void | dlgClose () |
| Emitted when the "Close" button is clicked. | |
| void | dlgCancel () |
| Emitted when the "Cancel" button is clicked. | |
Public Member Functions | |
| QtxDialog (QWidget *=0, bool=false, bool=false, const int=Standard, Qt::WindowFlags=0) | |
| Constructor. | |
| virtual | ~QtxDialog () |
| Destructor. | |
| void | setDialogFlags (const int) |
| Set specified dialog box flags. | |
| void | clearDialogFlags (const int) |
| Clear specified the dialog flags. | |
| bool | testDialogFlags (const int) const |
| Test specified dialog flags. | |
| void | setButtonFlags (const int) |
| Add specified control button(s) to the dialog box. | |
| void | clearButtonFlags (const int) |
| Remove specified control button(s) from the dialog box. | |
| bool | testButtonFlags (const int) const |
| Test specified buttons. | |
| int | buttonPosition (const int) const |
| Get specified control button position. | |
| void | setButtonPosition (const int, const int=-1) |
| Set the specified control button(s) position. | |
| void | setPlacePosition (const int, const int) |
| Set button position for all buttons in specified area. | |
| int | placePolicy (const int) const |
| Get buttons layouting policy for the specified area. | |
| void | setPlacePolicy (const int, const int) |
| set buttons layouting policy for the specified area. | |
| void | setButtonPlace (const int, const int) |
| Move specified button(s) into specified area. | |
| QString | buttonText (const int) |
| Get specified button's text. | |
| void | setButtonText (const int, const QString &text) |
| Set specified button's text. | |
| void | setButtonFocus (const int) |
| Sets the keyboard focus to the specified button. | |
| bool | hasButtonFocus (const int) const |
| Check if specified button has keyboard focus. | |
| bool | isButtonEnabled (const int) const |
| Get "enabled" status of the specified button(s). | |
| void | setButtonEnabled (const bool, const int) |
| Enable/disable specified button(s). | |
| bool | isBorderEnabled (const int) const |
| Check if border is enabled. | |
| void | setBorderEnabled (const bool, const int) |
| Show/hide border for the specified button area. | |
| void | removeButton (const int) |
| Remove user button. | |
| int | insertButton (const QString &, const int=BottomArea) |
| Add user button to the dialog box. | |
| QIntList | userButtonIds () const |
| Get all user button IDs. | |
| QAbstractButton * | userButton (const int) const |
| Get user button by the specified id. | |
| uint | setAlignment (uint align) |
| Sets alignment policy. | |
Static Public Member Functions | |
| static void | setUnits (QLabel *, const QString &) |
| Set measure units to the specified label. | |
Protected Types | |
| typedef QMap< int, QAbstractButton * > | ButtonMap |
| button map | |
Protected Slots | |
| virtual void | accept () |
| Accept the dialog box. | |
| virtual void | reject () |
| Reject the dialog box. | |
Protected Member Functions | |
| QFrame * | mainFrame () const |
| Get dialog box main frame widget. | |
| virtual bool | acceptData () const |
| Check if data entered by the user is valid. | |
| virtual bool | rejectData () const |
| Check if dialog box can be cancelled. | |
| virtual QAbstractButton * | createButton (QWidget *) |
| Create new user button. | |
| QAbstractButton * | button (const int) const |
| Get button by the specified ID. | |
| ButtonMap | buttons (const int=All) const |
| Get buttons by the specified IDs. | |
| int | buttonId (const QAbstractButton *) const |
| Get specified button's identifier. | |
| int | buttonPosition (QAbstractButton *) const |
| Get position of specified button. | |
| virtual void | showEvent (QShowEvent *) |
| Align this dialog according to the parent widget and alignment policy before the dialog box is shown. | |
| virtual void | hideEvent (QHideEvent *) |
| Process all existing events when dialog box is hidden. | |
| virtual void | closeEvent (QCloseEvent *) |
| Called when user closes dialog box. | |
| virtual void | childEvent (QChildEvent *) |
| Update dialog box layout when the size grip is added. | |
| virtual void | keyPressEvent (QKeyEvent *) |
| Process key pressing event. | |
Private Types | |
| typedef QMap< int, Area * > | AreaMap |
| button area map | |
| typedef QMap< int, int > | PositionMap |
| button position map | |
Private Slots | |
| void | onAccept () |
| This slot is called when user presses on of the buttons "OK", "Yes", etc. | |
| void | onReject () |
| This slot is called when user presses on of the buttons "Cancel", "No", "Close". | |
| void | onButton () |
| Process user button click event. | |
| void | onSizeGripDestroyed () |
| Update dialog box layout when the size grip is destroyed. | |
| void | onDestroyed (QObject *) |
| Watch for the user button destroying. | |
Private Member Functions | |
| void | adjustButtons () |
| Adjust buttons (set equal size for all buttons). | |
| void | emitSignal () |
| Emit signal correspondingly to the control button. | |
Private Attributes | |
| AreaMap | myArea |
| buttons areas map | |
| ButtonMap | myButton |
| buttons map | |
| PositionMap | myPosition |
| buttons position map | |
| bool | myInited |
| dialog's "initialized" flag | |
| const QObject * | mySender |
| signal sender | |
| uint | myAlignment |
| dialog box alignment type | |
| QFrame * | myMainFrame |
| main frame | |
| int | myButtonFlags |
| button flags | |
| int | myDialogFlags |
| dialog flags | |
Friends | |
| class | Area |
typedef QMap<int, QAbstractButton*> QtxDialog.ButtonMap [protected] |
typedef QMap<int, Area*> QtxDialog.AreaMap [private] |
typedef QMap<int, int> QtxDialog.PositionMap [private] |
| QtxDialog::QtxDialog | ( | QWidget * | parent = 0, |
| bool | modal = false, |
||
| bool | allowResize = false, |
||
| const int | f = Standard, |
||
| Qt::WindowFlags | wf = 0 |
||
| ) |
Construct a dialog with specified parent and name. By default non-modal, non-resizable with the OK, Cancel and Help buttons dialog box is created.
| parent | parent widget |
| modal | if true dialog box is modal |
| allowResize | if true then dialog can be resized by user |
| f | specified control buttons for dialog box (QtxDialog.ButtonFlags) |
| wf | dialog box flags (Qt.WindowFlags) |
References All, Apply, Area, BottomArea, Cancel, Center, Close, dlgApply(), dlgHelp(), Help, Horizontal, Left, LeftArea, main(), myArea, myButton, myButtonFlags, myMainFrame, No, OK, onAccept(), onDestroyed(), onReject(), Right, RightArea, QtxDialog.Area.setBorderWidget(), setButtonPlace(), setButtonPosition(), TopArea, update(), Vertical, and Yes.
| QtxDialog::~QtxDialog | ( | ) | [virtual] |
| void QtxDialog::setDialogFlags | ( | const int | f | ) |
| f | dialog box flags (QtxDialog.DialogFlags) |
References myDialogFlags.
| void QtxDialog::clearDialogFlags | ( | const int | f | ) |
| f | dialog box flags (QtxDialog.DialogFlags) |
References myDialogFlags.
| bool QtxDialog::testDialogFlags | ( | const int | f | ) | const |
true if specified dialog box falgs are set References myDialogFlags.
| void QtxDialog::setButtonFlags | ( | const int | f | ) |
| f | ORed buttons flags (Qtx.ButtonFlags) |
References myButtonFlags, and update().
| void QtxDialog::clearButtonFlags | ( | const int | f | ) |
| f | ORed buttons flags (Qtx.ButtonFlags) |
References myButtonFlags, and update().
| bool QtxDialog::testButtonFlags | ( | const int | f | ) | const |
true if specified control buttons are used in the dialog box References myButtonFlags.
| int QtxDialog::buttonPosition | ( | const int | id | ) | const |
| id | control button ID (QtxDialog.ButtonFlags) |
References myPosition.
| void QtxDialog::setButtonPosition | ( | const int | pos, |
| const int | id = -1 |
||
| ) |
| id | control button(s) ID (QtxDialog.ButtonFlags) |
| pos | button(s) position (QtxDialog.ButtonPosition) |
References button(), buttons(), myArea, and myPosition.
| void QtxDialog::setPlacePosition | ( | const int | pos, |
| const int | area | ||
| ) |
| pos | button(s) position (QtxDialog.ButtonPosition) |
| area | buttons area (QtxDialog.ButtonArea) |
References QtxDialog.Area.contains(), QtxDialog.Area.layoutButtons(), myArea, myButton, and myPosition.
| int QtxDialog::placePolicy | ( | const int | area | ) | const |
| void QtxDialog::setPlacePolicy | ( | const int | policy, |
| const int | area | ||
| ) |
| policy | buttons layouting policy (QtxDialog.PlacePolicy) |
| area | buttons area (QtxDialog.ButtonArea) |
References myArea.
| void QtxDialog::setButtonPlace | ( | const int | area, |
| const int | id | ||
| ) |
| area | buttons area (QtxDialog.ButtonArea) |
| id | control button(s) ID (QtxDialog.ButtonFlags) |
References buttons(), QtxDialog.Area.insertButton(), myArea, and QtxDialog.Area.removeButton().
| QString QtxDialog::buttonText | ( | const int | id | ) |
| id | control button ID (QtxDialog.ButtonFlags) |
References button().
| void QtxDialog::setButtonText | ( | const int | id, |
| const QString & | text | ||
| ) |
| id | control button ID (QtxDialog.ButtonFlags) |
| text | button's text |
References adjustButtons(), and button().
| void QtxDialog::setButtonFocus | ( | const int | id | ) |
| id | control button ID (QtxDialog.ButtonFlags) |
References button().
| bool QtxDialog::hasButtonFocus | ( | const int | id | ) | const |
| id | control button ID (QtxDialog.ButtonFlags) |
true if specified button has keyboard focus References button().
| bool QtxDialog::isButtonEnabled | ( | const int | id | ) | const |
| id | control button(s) ID (QtxDialog.ButtonFlags) |
true if all specified buttons are enabled. References buttons().
| void QtxDialog::setButtonEnabled | ( | const bool | on, |
| const int | id | ||
| ) |
| on | enable button(s) flag |
| id | control button(s) ID (QtxDialog.ButtonFlags) |
References buttons().
| bool QtxDialog::isBorderEnabled | ( | const int | area | ) | const |
| area | buttons area (QtxDialog.ButtonArea) |
true if border is enabled for specified button area. References myArea.
| void QtxDialog::setBorderEnabled | ( | const bool | on, |
| const int | area | ||
| ) |
Border is a line which separate main frame and control buttons.
| area | buttons area (QtxDialog.ButtonArea) |
| on | enable border flag |
References isBorderEnabled(), and myArea.
| void QtxDialog::removeButton | ( | const int | id | ) |
If id is -1, all user buttons are removed.
| id | user button ID |
References myArea, myButton, myPosition, and update().
| int QtxDialog::insertButton | ( | const QString & | text, |
| const int | area = BottomArea |
||
| ) |
The button is inserted to the specified dialog box area. if the button is added successfully, the unique identificator of the added button is returned, otherwise -1 is returned.
| text | text of the added button |
| area | buttons area (QtxDialog.ButtonArea) |
References createButton(), QtxDialog.Area.insertButton(), Left, myArea, myButton, myPosition, onButton(), onDestroyed(), and update().
| QIntList QtxDialog::userButtonIds | ( | ) | const |
References myButton.
| QAbstractButton * QtxDialog::userButton | ( | const int | id | ) | const |
| id | user button ID |
References myButton.
| uint QtxDialog::setAlignment | ( | uint | align | ) |
Use the function before the the dialog is first time shown. If dialog flag AlignOnce is set then alignment is performed only once, otherwise the dialog is aligned each time when it is shown. Dialog box is aligned relatively to its parent. By default, dialog box is aligned to the center of the parent widget (usually desktop or another dialog box).
| align | alignment flag(s) (Qtx.AlignmentFlags) |
References myAlignment.
| void QtxDialog::setUnits | ( | QLabel * | aLabel, |
| const QString & | aUnits | ||
| ) | [static] |
In the dialog box label the measure units are closed in braces. If measure units do not exist they will be added.
For example:
// create label "Radius" QLabel* aLabel = new QLabel( "Radius", mainFrame() ); // set measure units to "mm" setUnits( aLabel, "mm" ) // => aLabel contains 'Radius (mm)' // set measure units to "cm" setUnits( aLabel, "cm" ) // => aLabel contains 'Radius (cm)' // create label "Radius" with initially not set measure units QLabel* aLabel = new QLabel( "Radius ():", mainFrame() ); // set measure units to "mm" setUnits( aLabel, "mm" ) // => aLabel contains 'Radius (mm):' // set measure units to "cm" setUnits( aLabel, "cm" ) // => aLabel contains 'Radius (cm):'
| aLabel | label widget |
| aUnits | measure units |
| void QtxDialog::dlgButton | ( | int | id | ) | [signal] |
| id | user button identificator |
| void QtxDialog::dlgParamChanged | ( | ) | [signal] |
| void QtxDialog::dlgHelp | ( | ) | [signal] |
| void QtxDialog::dlgApply | ( | ) | [signal] |
| void QtxDialog::dlgOk | ( | ) | [signal] |
| void QtxDialog::dlgNo | ( | ) | [signal] |
| void QtxDialog::dlgYes | ( | ) | [signal] |
| void QtxDialog::dlgClose | ( | ) | [signal] |
| void QtxDialog::dlgCancel | ( | ) | [signal] |
| void QtxDialog::update | ( | ) | [slot] |
References adjustButtons(), myArea, myButton, and testButtonFlags().
| void QtxDialog::setVisible | ( | bool | on | ) | [virtual, slot] |
Re-implemented from Qt.
| on | show/hide flag |
Reimplemented in LightApp_PreferencesDlg, and QtxPathDialog.
References myInited, SetFocus, and testDialogFlags().
| void QtxDialog::accept | ( | ) | [protected, virtual, slot] |
This method is used when any accept button is pressed (usually "OK", "Yes", etc).
If dialog flag QtxDialog.Accept is set, this function invokes acceptData() method, which should in this case return true to allow further processing.
If acceptData() returns false, this function just returns.
If acceptData() returns true, the Accepted result is set and signal according to the pressed control button is emitted. Then the default implementation of accept() method is called (which hides the dialog box and, depending on the dialog box flags, can close and destroy it).
Reimplemented in LightApp_PreferencesDlg, and Style_PrefDlg.
References Accept, acceptData(), button(), Close, emitSignal(), mySender, OK, testButtonFlags(), testDialogFlags(), and Yes.
| void QtxDialog::reject | ( | ) | [protected, virtual, slot] |
This method is used when any reject button is pressed (usually "Close", "Cancel", "No", etc).
If dialog flag QtxDialog.Reject is set, this function invokes rejectData() method, which should in this case return true to allow further processing.
If rejectData() returns false, this function just returns.
If rejectData() returns true, the Rejected result is set and signal according to the pressed control button is emitted. Then the default implementation of reject() method is called (which hides the dialog box and, depending on the dialog box flags, can close and destroy it).
Reimplemented in LightApp_PreferencesDlg.
References button(), Cancel, Close, emitSignal(), mySender, No, Reject, rejectData(), testButtonFlags(), and testDialogFlags().
| void QtxDialog::onAccept | ( | ) | [private, slot] |
Call accept() method.
References accept(), mySender, and PyInterp.obj.
| void QtxDialog::onReject | ( | ) | [private, slot] |
Call reject() method.
References mySender, PyInterp.obj, and reject().
| void QtxDialog::onButton | ( | ) | [private, slot] |
This method is called when user presses one of custom user buttons. Emits signal dlgButton(int) with identificator of the clicked user button passed as parameter.
References buttonId(), and dlgButton().
| void QtxDialog::onSizeGripDestroyed | ( | ) | [private, slot] |
| void QtxDialog::onDestroyed | ( | QObject * | obj | ) | [private, slot] |
| obj | button being destroyed |
References buttonId(), myArea, myButton, and myPosition.
| QFrame * QtxDialog::mainFrame | ( | ) | const [protected] |
Main frame is an internal widget which should contains all elements of dialog box except control buttons.
References myMainFrame.
| bool QtxDialog::acceptData | ( | ) | const [protected, virtual] |
This method can be re-implemented in the successor class if it requires to check user input consistency. Default implementation returns true.
This method is called if dialog flag QtxDialog.Accept is set. If this method returns true, then dialog will be accepted and closed.
true if user input is valid Reimplemented in QtxPathDialog.
| bool QtxDialog::rejectData | ( | ) | const [protected, virtual] |
This method can be re-implemented in the successor class if it requires to check possibility to cancel dialog box safely. Default implementation returns true.
This method is called if dialog flag QtxDialog.Reject is set. If this method returns true, then dialog will be rejected and closed.
true if dialog box can be cancelled | QAbstractButton * QtxDialog::createButton | ( | QWidget * | parent | ) | [protected, virtual] |
This method is invoked from method insertButton().
| parent | parent widget |
| QAbstractButton * QtxDialog::button | ( | const int | f | ) | const [protected] |
| f | control button ID (QtxDialog.ButtonFlags) |
References myButton.
| QtxDialog::ButtonMap QtxDialog::buttons | ( | const int | f = All | ) | const [protected] |
| f | control button(s) ID(s) (QtxDialog.ButtonFlags) |
References myButton.
| int QtxDialog::buttonId | ( | const QAbstractButton * | b | ) | const [protected] |
| int QtxDialog::buttonPosition | ( | QAbstractButton * | b | ) | const [protected] |
| b | button |
References buttonId(), and buttonPosition().
| void QtxDialog::showEvent | ( | QShowEvent * | e | ) | [protected, virtual] |
Re-implemented from Qt.
| e | show event |
References AlignOnce, Qtx.alignWidget(), myAlignment, myInited, and testDialogFlags().
| void QtxDialog::hideEvent | ( | QHideEvent * | e | ) | [protected, virtual] |
Re-implemented from Qt.
| e | hide event |
| void QtxDialog::closeEvent | ( | QCloseEvent * | ) | [protected, virtual] |
| void QtxDialog::childEvent | ( | QChildEvent * | e | ) | [protected, virtual] |
| void QtxDialog::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Re-implemented from Qt.
Call reject() if "Escape" key is pressed. Call accept() if "Ctrl+Enter" key-sequence is pressed. Process "F1" key and emit signal dlgHelp(). Transfer "Ctrl+(Shift+)Tab" key-sequence press event to the child Tab widget (if there is any).
| e | key press event |
Reimplemented in Style_PrefDlg, and VTKViewer_MarkerDlg.
References accept(), Apply, dlgApply(), dlgHelp(), Help, isButtonEnabled(), OK, reject(), testButtonFlags(), and Yes.
| void QtxDialog::adjustButtons | ( | ) | [private] |
References myArea.
| void QtxDialog::emitSignal | ( | ) | [private] |
References buttonId(), Cancel, Close, dlgCancel(), dlgClose(), dlgNo(), dlgOk(), dlgYes(), mySender, No, OK, and Yes.
friend class Area [friend] |
AreaMap QtxDialog.myArea [private] |
ButtonMap QtxDialog.myButton [private] |
PositionMap QtxDialog.myPosition [private] |
bool QtxDialog.myInited [private] |
const QObject* QtxDialog.mySender [private] |
uint QtxDialog.myAlignment [private] |
QFrame* QtxDialog.myMainFrame [private] |
int QtxDialog.myButtonFlags [private] |
int QtxDialog.myDialogFlags [private] |