Version: 6.3.1
Data Structures | Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Types | Protected Slots | Protected Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes | Friends

QtxDialog Class Reference

Generic dialog box class.

#include <QtxDialog.h>

Inheritance diagram for QtxDialog:
Inheritance graph

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.
QAbstractButtonuserButton (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

QFramemainFrame () 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 QAbstractButtoncreateButton (QWidget *)
 Create new user button.
QAbstractButtonbutton (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 QObjectmySender
 signal sender
uint myAlignment
 dialog box alignment type
QFramemyMainFrame
 main frame
int myButtonFlags
 button flags
int myDialogFlags
 dialog flags

Friends

class Area

Member Typedef Documentation

typedef QMap<int, QAbstractButton*> QtxDialog.ButtonMap [protected]
typedef QMap<int, Area*> QtxDialog.AreaMap [private]
typedef QMap<int, int> QtxDialog.PositionMap [private]

Member Enumeration Documentation

Enumerator:
Position 

buttons are placed according their position

Expand 

buttons occupy all available space

Uniform 

buttons are uniformly placed in the area

Enumerator:
TopArea 

horizontal area at the top side of the dialog box

BottomArea 

horizontal area at the bottom side of the dialog box

LeftArea 

vertical area at the left side of the dialog box

RightArea 

vertical area at the right side of the dialog box

Enumerator:
Left 

set button left-most

Right 

set button right-most

Center 

place button in the center

Top 

set button top-most

Bottom 

set button bottom-most

Enumerator:
None 

no button used

OK 

OK button.

Apply 

Apply button.

Cancel 

Cancel button.

Yes 

Yes button.

No 

No button.

Close 

Close button.

Help 

Help button.

OKCancel 

OK & Cancel button.

YesNo 

Yes & No buttons.

Standard 

OK, Cancel & Help buttons.

All 

all buttons

Enumerator:
Accept 

allow dialog box accepting control

Reject 

allow dialog box rejecting control

AlignOnce 

align dialog box only when it is first time shown

SetFocus 

allow to set focus on dialog box when it is shown (user can use setFocusProxy() and specify own initial focus widget)


Constructor & Destructor Documentation

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.

Parameters:
parentparent widget
modalif true dialog box is modal
allowResizeif true then dialog can be resized by user
fspecified control buttons for dialog box (QtxDialog.ButtonFlags)
wfdialog 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]

Member Function Documentation

void QtxDialog::setDialogFlags ( const int  f)
Parameters:
fdialog box flags (QtxDialog.DialogFlags)
See also:
clearDialogFlags(), testDialogFlags(), acceptData(), rejectData()

References myDialogFlags.

void QtxDialog::clearDialogFlags ( const int  f)
Parameters:
fdialog box flags (QtxDialog.DialogFlags)
See also:
setDialogFlags(), testDialogFlags()

References myDialogFlags.

bool QtxDialog::testDialogFlags ( const int  f) const
Returns:
true if specified dialog box falgs are set
See also:
setDialogFlags(), clearDialogFlags()

References myDialogFlags.

void QtxDialog::setButtonFlags ( const int  f)
Parameters:
fORed buttons flags (Qtx.ButtonFlags)
See also:
clearButtonFlags(), testButtonFlags()

References myButtonFlags, and update().

void QtxDialog::clearButtonFlags ( const int  f)
Parameters:
fORed buttons flags (Qtx.ButtonFlags)
See also:
setButtonFlags(), testButtonFlags()

References myButtonFlags, and update().

bool QtxDialog::testButtonFlags ( const int  f) const
Returns:
true if specified control buttons are used in the dialog box
See also:
setButtonFlags(), clearButtonFlags()

References myButtonFlags.

int QtxDialog::buttonPosition ( const int  id) const
Parameters:
idcontrol button ID (QtxDialog.ButtonFlags)
Returns:
button's position (QtxDialog.ButtonPosition) or -1 if it is not set or invalid id is given
See also:
setButtonPosition()

References myPosition.

void QtxDialog::setButtonPosition ( const int  pos,
const int  id = -1 
)
Parameters:
idcontrol button(s) ID (QtxDialog.ButtonFlags)
posbutton(s) position (QtxDialog.ButtonPosition)

References button(), buttons(), myArea, and myPosition.

void QtxDialog::setPlacePosition ( const int  pos,
const int  area 
)
int QtxDialog::placePolicy ( const int  area) const
Parameters:
areabuttons area (QtxDialog.ButtonArea)
See also:
setPlacePolicy()

References myArea.

void QtxDialog::setPlacePolicy ( const int  policy,
const int  area 
)
Parameters:
policybuttons layouting policy (QtxDialog.PlacePolicy)
areabuttons area (QtxDialog.ButtonArea)
See also:
placePolicy()

References myArea.

void QtxDialog::setButtonPlace ( const int  area,
const int  id 
)
Parameters:
areabuttons area (QtxDialog.ButtonArea)
idcontrol button(s) ID (QtxDialog.ButtonFlags)

References buttons(), QtxDialog.Area.insertButton(), myArea, and QtxDialog.Area.removeButton().

QString QtxDialog::buttonText ( const int  id)
Parameters:
idcontrol button ID (QtxDialog.ButtonFlags)
Returns:
button's text
See also:
setButtonText()

References button().

void QtxDialog::setButtonText ( const int  id,
const QString &  text 
)
Parameters:
idcontrol button ID (QtxDialog.ButtonFlags)
textbutton's text
See also:
buttonText()

References adjustButtons(), and button().

void QtxDialog::setButtonFocus ( const int  id)
Parameters:
idcontrol button ID (QtxDialog.ButtonFlags)
See also:
hasButtonFocus()

References button().

bool QtxDialog::hasButtonFocus ( const int  id) const
Parameters:
idcontrol button ID (QtxDialog.ButtonFlags)
Returns:
true if specified button has keyboard focus
See also:
setButtonFocus()

References button().

bool QtxDialog::isButtonEnabled ( const int  id) const
Parameters:
idcontrol button(s) ID (QtxDialog.ButtonFlags)
Returns:
true if all specified buttons are enabled.
See also:
setButtonEnabled()

References buttons().

void QtxDialog::setButtonEnabled ( const bool  on,
const int  id 
)
Parameters:
onenable button(s) flag
idcontrol button(s) ID (QtxDialog.ButtonFlags)
See also:
isButtonEnabled()

References buttons().

bool QtxDialog::isBorderEnabled ( const int  area) const
Parameters:
areabuttons area (QtxDialog.ButtonArea)
Returns:
true if border is enabled for specified button area.
See also:
setBorderEnabled()

References myArea.

void QtxDialog::setBorderEnabled ( const bool  on,
const int  area 
)

Border is a line which separate main frame and control buttons.

Parameters:
areabuttons area (QtxDialog.ButtonArea)
onenable border flag
See also:
isBorderEnabled()

References isBorderEnabled(), and myArea.

void QtxDialog::removeButton ( const int  id)

If id is -1, all user buttons are removed.

Parameters:
iduser button ID
See also:
insertButton(), userButton(), userButtonIds()

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.

Parameters:
texttext of the added button
areabuttons area (QtxDialog.ButtonArea)
Returns:
button ID
See also:
removeButton(), userButton(), userButtonIds()

References createButton(), QtxDialog.Area.insertButton(), Left, myArea, myButton, myPosition, onButton(), onDestroyed(), and update().

QIntList QtxDialog::userButtonIds ( ) const
Returns:
list of user buttons identificators
See also:
insertButton(), removeButton(), userButton()

References myButton.

QAbstractButton * QtxDialog::userButton ( const int  id) const
Parameters:
iduser button ID
Returns:
user button or 0 if it is not found
See also:
insertButton(), removeButton(), userButtonIds()

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).

Parameters:
alignalignment flag(s) (Qtx.AlignmentFlags)
Returns:
previous alignment policy

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):'
Parameters:
aLabellabel widget
aUnitsmeasure units
void QtxDialog::dlgButton ( int  id) [signal]
Parameters:
iduser 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]
void QtxDialog::setVisible ( bool  on) [virtual, slot]

Re-implemented from Qt.

Parameters:
onshow/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).

See also:
acceptData()

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).

See also:
rejectData()

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]
Parameters:
objbutton 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.

Returns:
main frame widget

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.

Returns:
true if user input is valid
See also:
accept()

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.

Returns:
true if dialog box can be cancelled
See also:
reject()
QAbstractButton * QtxDialog::createButton ( QWidget parent) [protected, virtual]

This method is invoked from method insertButton().

Parameters:
parentparent widget
Returns:
new user button
QAbstractButton * QtxDialog::button ( const int  f) const [protected]
Parameters:
fcontrol button ID (QtxDialog.ButtonFlags)
Returns:
button or 0 if id is invalid

References myButton.

QtxDialog::ButtonMap QtxDialog::buttons ( const int  f = All) const [protected]
Parameters:
fcontrol button(s) ID(s) (QtxDialog.ButtonFlags)
Returns:
button map

References myButton.

int QtxDialog::buttonId ( const QAbstractButton b) const [protected]
Parameters:
bbutton
Returns:
button ID

References myButton.

int QtxDialog::buttonPosition ( QAbstractButton b) const [protected]
Parameters:
bbutton
Returns:
button position (QtxDialog.ButtonPosition)

References buttonId(), and buttonPosition().

void QtxDialog::showEvent ( QShowEvent *  e) [protected, virtual]

Re-implemented from Qt.

Parameters:
eshow event

References AlignOnce, Qtx.alignWidget(), myAlignment, myInited, and testDialogFlags().

void QtxDialog::hideEvent ( QHideEvent *  e) [protected, virtual]

Re-implemented from Qt.

Parameters:
ehide event
void QtxDialog::closeEvent ( QCloseEvent *  ) [protected, virtual]

Call reject() method.

Parameters:
eclose event (not used)

References reject().

void QtxDialog::childEvent ( QChildEvent *  e) [protected, virtual]

Re-implemented from Qt.

Parameters:
echild event

References onSizeGripDestroyed().

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).

Parameters:
ekey 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]

Friends And Related Function Documentation

friend class Area [friend]

Field Documentation

bool QtxDialog.myInited [private]
const QObject* QtxDialog.mySender [private]
uint QtxDialog.myAlignment [private]
int QtxDialog.myButtonFlags [private]
int QtxDialog.myDialogFlags [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS