A set of helpful utility functions. More...
#include <Qtx.h>

Data Structures | |
| class | Localizer |
| Localization helper. More... | |
Public Types | |
| enum | AlignmentFlags { AlignLeft = Qt::AlignLeft, AlignLeading = Qt::AlignLeading, AlignRight = Qt::AlignRight, AlignTrailing = Qt::AlignTrailing, AlignHCenter = Qt::AlignHCenter, AlignJustify = Qt::AlignJustify, AlignAbsolute = Qt::AlignAbsolute, AlignHorizontal_Mask = Qt::AlignHorizontal_Mask, AlignTop = Qt::AlignTop, AlignBottom = Qt::AlignBottom, AlignVCenter = Qt::AlignVCenter, AlignVertical_Mask = Qt::AlignVertical_Mask, AlignCenter = Qt::AlignCenter, AlignOutLeft = Qt::AlignVCenter << 2, AlignOutRight = AlignOutLeft << 2, AlignOutTop = AlignOutRight << 2, AlignOutBottom = AlignOutTop << 2 } |
Widget alignment flags. More... | |
| enum | PathType { PT_OpenFile, PT_SaveFile, PT_Directory } |
Path type, indicates required directory/file operation. More... | |
| enum | { AppropriateRole = Qt::UserRole + 100 } |
Custom data roles. More... | |
| enum | Appropriate { Shown, Hidden, Toggled } |
| enum | SubstMode { Always, Never, Auto } |
Environment variables substitution mode. More... | |
| enum | VisibilityState { ShownState, HiddenState, UnpresentableState } |
object visibility state More... | |
| enum | HeaderViewFlags { ShowText = 0x001, ShowIcon = 0x010, ShowAll = ShowText | ShowIcon } |
Header view flags. More... | |
| enum | CustomDataType { IdType } |
Static Public Member Functions | |
| static QString | toQString (const char *, const int=-1) |
| Convert character array (ASCII string) to the QString. | |
| static QString | toQString (const short *, const int=-1) |
| Convert integer array (UNICODE string) to the QString. | |
| static QString | toQString (const unsigned char *, const int=-1) |
| Convert character array (ASCII string) to the QString. | |
| static QString | toQString (const unsigned short *, const int=-1) |
| Convert integer array (UNICODE string) to the QString. | |
| static void | setTabOrder (QWidget *,...) |
| Set tab order for specified list of widgets. | |
| static void | setTabOrder (const QWidgetList &) |
| Set tab order for specified list of widgets. | |
| static void | alignWidget (QWidget *, const QWidget *, const int) |
| Align widget src relative to widget ref acording to the alignment flags alignFlags. | |
| static void | simplifySeparators (QWidget *, const bool=true) |
| Remove (recursively) unnecessary separators from the menu or toolbar. | |
| static bool | isParent (QObject *, QObject *) |
Return true if specified parent is a parent object of given child (in terms of QObject). | |
| static QObject * | findParent (QObject *, const char *) |
| Find the parent object of class specified by className (in terms of QObject). | |
| static QString | dir (const QString &, const bool=true) |
| Return directory part of the file path. | |
| static QString | file (const QString &, const bool=true) |
| Return file name part of the file path. | |
| static QString | extension (const QString &, const bool=false) |
| Return extension part of the file path. | |
| static QString | library (const QString &) |
| Convert the given parameter to the platform-specific library name. | |
| static QString | tmpDir () |
| Get the temporary directory name. | |
| static bool | mkDir (const QString &) |
| Create directory recursively including all intermediate sub directories. | |
| static bool | rmDir (const QString &) |
| Remove directory recursively including all subdirectories and files. | |
| static bool | dos2unix (const QString &) |
| Convert text file from DOS format to UNIX. | |
| static QString | addSlash (const QString &) |
| Add a slash (platform-specific) to the end of path if it is not already there. | |
| static QCompleter * | pathCompleter (const PathType, const QString &=QString()) |
| Create path completer which can be used in the widgets to provide auto completions. | |
| static QString | findEnvVar (const QString &, int &, int &) |
| Parse given string to retrieve environment variable. | |
| static QString | makeEnvVarSubst (const QString &, const SubstMode=Auto) |
| Substitute environment variables by their values. | |
| static int | rgbSet (const QColor &) |
| Pack the specified color into integer RGB set. | |
| static int | rgbSet (const int, const int, const int) |
| Pack the specified RGB color components into integer RGB set. | |
| static QColor | rgbSet (const int) |
| Unpack the specified integer RGB set to the color. | |
| static void | rgbSet (const int, int &, int &, int &) |
| Unpack the specified integer RGB set to the three RGB components. | |
| static QColor | scaleColor (const int, const int, const int) |
| Return the color specified by the index between min (blue) and max (red). | |
| static void | scaleColors (const int, QColorList &) |
| Generate required number of colors aligned from blue to red. | |
| static QPixmap | scaleIcon (const QPixmap &, const unsigned, const unsigned=0) |
| Scale the pixmap to the required size. | |
| static QImage | grayscale (const QImage &) |
| Convert given image to the grayscale format. | |
| static QPixmap | grayscale (const QPixmap &) |
| Convert given pixmap to the grayscale format. | |
| static QImage | transparentImage (const int, const int, const int=-1) |
| Create transparent image. | |
| static QPixmap | transparentPixmap (const int, const int, const int=-1) |
| Create transparent pixmap. | |
| static QPixmap | composite (const QPixmap &, const int, const int, const QPixmap &=QPixmap()) |
| Create composite pixmap. | |
| static QString | colorToString (const QColor &) |
| Convert color to the string representation. | |
| static bool | stringToColor (const QString &, QColor &) |
| Create color from the string representation. | |
| static QString | gradientToString (const QLinearGradient &) |
| Dump linear gradient to the string description. | |
| static QString | gradientToString (const QRadialGradient &) |
| Dump radial gradient to the string description. | |
| static QString | gradientToString (const QConicalGradient &) |
| Dump conical gradient to the string description. | |
| static bool | stringToLinearGradient (const QString &, QLinearGradient &) |
| Create linear gradient from its string representation. | |
| static bool | stringToRadialGradient (const QString &, QRadialGradient &) |
| Create radial gradient from its string representation. | |
| static bool | stringToConicalGradient (const QString &, QConicalGradient &) |
| Create conical gradient from its string representation. | |
| static void * | getDisplay () |
| Open the default X display and returns pointer to it. This method is available on Linux only. | |
| static Qt::HANDLE | getVisual () |
| Returns pointer to X visual suitable for 3D rendering. This method is available on Linux only. | |
The class implements a set of the static functions which can be used for the different purposes:
| enum Qtx::AlignmentFlags |
| enum Qtx::PathType |
| enum Qtx::Appropriate |
| enum Qtx::SubstMode |
| enum Qtx::VisibilityState |
| enum Qtx::HeaderViewFlags |
| enum Qtx::CustomDataType |
| QString Qtx::toQString | ( | const char * | str, |
| const int | len = -1 |
||
| ) | [static] |
| str | character array |
| len | array length, if < 0, the array should be zero-terminated |
| QString Qtx::toQString | ( | const short * | str, |
| const int | len = -1 |
||
| ) | [static] |
| str | integer array |
| len | array length, if < 0, the array should be zero-terminated |
References toQString().
| QString Qtx::toQString | ( | const unsigned char * | str, |
| const int | len = -1 |
||
| ) | [static] |
| str | character array |
| len | array length, if < 0, the array should be zero-terminated |
| QString Qtx::toQString | ( | const unsigned short * | str, |
| const int | len = -1 |
||
| ) | [static] |
| str | integer array |
| len | array length, if < 0, the array should be zero-terminated |
| void Qtx::setTabOrder | ( | QWidget * | first, |
| ... | |||
| ) | [static] |
The function has arbitrary number of parameters, each should be hovewer of QWidget* type. Last parameter should be null pointer.
| first | first widget in the sequence |
| void Qtx::setTabOrder | ( | const QWidgetList & | widgets | ) | [static] |
| widgets | list of widgets |
References setTabOrder().
| src | source widget (being aligned) |
| ref | reference widget (source widget being aligned to) |
| alignFlags | alignment flags (Qtx.AlignmentFlags) |
References AlignBottom, AlignHCenter, AlignLeft, AlignOutBottom, AlignOutLeft, AlignOutRight, AlignOutTop, AlignRight, AlignTop, and AlignVCenter.
| void Qtx::simplifySeparators | ( | QWidget * | wid, |
| const bool | recursive = true |
||
| ) | [static] |
| wid | widget, should be of QMenu* or QToolBar* class |
This function works recursively. It means that true is also returned if parent is a grand-father, grand-grand-father, etc of child. If the same object is given as both parent and child, true is also returned.
| child | child object |
| parent | parent object |
true if the parent is a parent of child References PyInterp.obj.
| obj | current object |
| className | class name of the parent |
| QString Qtx::dir | ( | const QString & | path, |
| const bool | abs = true |
||
| ) | [static] |
If the file path does not include directory part (the file is in the current directory), null string is returned.
| path | file path |
| abs | if true (default) path parameter is treated as absolute file path |
| QString Qtx::file | ( | const QString & | path, |
| const bool | withExt = true |
||
| ) | [static] |
| path | file path |
| withExt | if true (default) complete file name (with all extension except the last) is returned, otherwise only base name is returned |
| QString Qtx::extension | ( | const QString & | path, |
| const bool | full = false |
||
| ) | [static] |
| path | file path |
| full | if true complete extension (all extensions, dot separated) is returned, otherwise (default) only last extension is returned |
| QString Qtx::library | ( | const QString & | str | ) | [static] |
The function appends platform-specific prefix (lib) and suffix (.dll/.so) to the library file name. For example, if str = "mylib", "libmylib.so" is returned for Linux and mylib.dll for Windows.
| str | short library name |
References addSlash(), dir(), extension(), and file().
| QString Qtx::tmpDir | ( | ) | [static] |
| bool Qtx::mkDir | ( | const QString & | dirPath | ) | [static] |
true if the directory is successfully created and false otherwise | bool Qtx::rmDir | ( | const QString & | thePath | ) | [static] |
true if the directory is successfully removed and false otherwise | bool Qtx::dos2unix | ( | const QString & | absName | ) | [static] |
The function replaces "LF/CR" symbols sequence by "LF" symbol.
| absName | file name |
true if the file is converted successfully and false in case of any error References dir().
| QString Qtx::addSlash | ( | const QString & | path | ) | [static] |
| path | directory path |
| QCompleter * Qtx::pathCompleter | ( | const PathType | type, |
| const QString & | filter = QString() |
||
| ) | [static] |
Create an instance of QCompleter class and returns the pointer on it. The calling function is responsible to the desstroying of the created completer object.
The QCompleter class provides completions based on a item model and can be used in such as QLineEdit and QComboBox. When the user starts typing a word, QCompleter suggests possible ways of completing the word, based on a word list.
| type | path type (Qtx.PathType) |
| filter | file/directory filters (list of wildcards, separated by ";;") |
References PT_Directory, PT_OpenFile, PT_SaveFile, and rx.
| QString Qtx::findEnvVar | ( | const QString & | str, |
| int & | start, | ||
| int & | len | ||
| ) | [static] |
Looks through the string for the patterns: ${name} or or name%. If string contains variable satisfying any pattern, the variable name is returned, start index of the variable is returned in the start parameter, and length of the variable is returned in the len parameter.
| str | string being processed |
| start | if variable is found, this parameter contains its starting position in the str |
| len | if variable is found, this parameter contains its length |
References rx.
| QString Qtx::makeEnvVarSubst | ( | const QString & | str, |
| const SubstMode | mode = Auto |
||
| ) | [static] |
Environment variable is substituted by its value.
| str | string to be processed |
References Always, findEnvVar(), and Never.
| int Qtx::rgbSet | ( | const QColor & | c | ) | [static] |
| c | unpacked color |
| int Qtx::rgbSet | ( | const int | r, |
| const int | g, | ||
| const int | b | ||
| ) | [static] |
| r | red component |
| g | green component |
| b | blue component |
| QColor Qtx::rgbSet | ( | const int | rgb | ) | [static] |
| void Qtx::rgbSet | ( | const int | rgb, |
| int & | r, | ||
| int & | g, | ||
| int & | b | ||
| ) | [static] |
| rgb | packed color |
| r | returned unpacked red component |
| g | returned unpacked green component |
| b | returned unpacked blue component |
| QColor Qtx::scaleColor | ( | const int | index, |
| const int | min, | ||
| const int | max | ||
| ) | [static] |
| index | color index |
| min | required minimum hue value |
| max | required maximum hue value |
| void Qtx::scaleColors | ( | const int | num, |
| QColorList & | lst | ||
| ) | [static] |
| num | required number of colors |
| lst | returned set of colors |
References scaleColor().
| QPixmap Qtx::scaleIcon | ( | const QPixmap & | icon, |
| const unsigned | w, | ||
| const unsigned | h = 0 |
||
| ) | [static] |
If h is 0 (default) the value of w is used instead (to create square pixmap).
| icon | pixmap to be resized |
| w | required pixmap width |
| h | required pixmap height |
| QImage Qtx::grayscale | ( | const QImage & | img | ) | [static] |
| img | initial image |
| QPixmap Qtx::grayscale | ( | const QPixmap & | pix | ) | [static] |
| QImage Qtx::transparentImage | ( | const int | w, |
| const int | h, | ||
| const int | d = -1 |
||
| ) | [static] |
| w | required image width |
| h | required image height |
| d | required image depth |
| QPixmap Qtx::transparentPixmap | ( | const int | w, |
| const int | h, | ||
| const int | d = -1 |
||
| ) | [static] |
| w | required image width |
| h | required pixmap height |
| d | required pixmap depth |
References transparentImage().
| QPixmap Qtx::composite | ( | const QPixmap & | pix, |
| const int | x, | ||
| const int | y, | ||
| const QPixmap & | dest = QPixmap() |
||
| ) | [static] |
Pixmap pix is drawn over pixmap dest with coordinates specified relatively to the upper left corner of dest. If dest is not given, the new empty pixmap with appropriate size created instead.
| pix | source pixmap |
| x | horizontal shift |
| y | vertical shift |
| dest | background pixmap |
References test_table.c, and transparentImage().
| QString Qtx::colorToString | ( | const QColor & | color | ) | [static] |
The resulting string is in the one of two possible formats (RR, GG, BB and AA value represent red, green, blue and alpha components of the color):
If color is invalid, null string is returned.
Backward conversion can be done with stringToColor() method.
| color | color to be converted |
| bool Qtx::stringToColor | ( | const QString & | str, |
| QColor & | color | ||
| ) | [static] |
The parameter str must be in the one of following formats (RR, GG, BB and AA value represent red, green, blue and alpha components of the color):
RR, GG, BB and optional AA values represent red, green, blue and alpha components of the color in hexadecimal form)RR, GG, BB and optional AA values represent red, green, blue and alpha components of the color in decimal form)RR, GG and BB values represent red, green and blue components of the color in hexadecimal form)Backward conversion can be done with colorToString() method.
| str | string representation of the color |
| color | resulting color value |
true if the conversion is successful and false otherwiseReferences rgbSet().
| QString Qtx::gradientToString | ( | const QLinearGradient & | gradient | ) | [static] |
| gradient | linear gradient to be converted |
References colorToString().
| QString Qtx::gradientToString | ( | const QRadialGradient & | gradient | ) | [static] |
| gradient | radial gradient to be converted |
References colorToString().
| QString Qtx::gradientToString | ( | const QConicalGradient & | gradient | ) | [static] |
| gradient | conical gradient to be converted |
References colorToString().
| bool Qtx::stringToLinearGradient | ( | const QString & | str, |
| QLinearGradient & | gradient | ||
| ) | [static] |
| str | string representation of the linear gradient |
| gradient | resulting linear gradient object |
true if the conversion is successful and false otherwise References test_table.c, and stringToColor().
| bool Qtx::stringToRadialGradient | ( | const QString & | str, |
| QRadialGradient & | gradient | ||
| ) | [static] |
| str | string representation of the radial gradient |
| gradient | resulting radial gradient object |
true if the conversion is successful and false otherwise References test_table.c, and stringToColor().
| bool Qtx::stringToConicalGradient | ( | const QString & | str, |
| QConicalGradient & | gradient | ||
| ) | [static] |
| str | string representation of the conical gradient |
| gradient | resulting conical gradient object |
true if the conversion is successful and false otherwise References test_table.a, test_table.c, and stringToColor().
| void * Qtx::getDisplay | ( | ) | [static] |
| Qt::HANDLE Qtx::getVisual | ( | ) | [static] |