|
QGIS API Documentation 4.1.0-Master (31622b25bb0)
|
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI. More...
Functions | |
| void | addDockWidget (QMainWindow *window, Qt::DockWidgetArea area, QDockWidget *dockwidget) |
| Add a dock widget to a main window. | |
| void | addTabifiedDockWidget (QMainWindow *window, Qt::DockWidgetArea area, QDockWidget *dockWidget, const QStringList &tabifyWith=QStringList(), bool raiseTab=false) |
| Add a dock widget to the given area and tabify it (if other dock widgets exist in the same area). | |
| QString | createFileFilter_ (QString const &format) |
| Create file filters suitable for use with QFileDialog. | |
| QString | createFileFilter_ (QString const &longName, QString const &glob) |
| Convenience function for readily creating file filters. | |
| QString | createWidgetKey (QWidget *widget, const QString &keyName=QString()) |
| Creates a key for the given widget that can be used to store related data in settings. | |
| QString | displayValueWithMaximumDecimals (const Qgis::DataType dataType, const double value, bool displayTrailingZeroes=false) |
| Returns a localized string representation of the value with the appropriate number of decimals supported by the dataType. | |
| QFont | getFont (bool &ok, const QFont &initial, const QString &title=QString()) |
| Show font selection dialog. | |
| QPair< QString, QString > GUI_EXPORT | getSaveAsImageName (QWidget *parent, const QString &message, const QString &defaultFilename=QString()) |
| A helper function to get an image name from the user. | |
| QSize | iconSize (bool dockableToolbar=false) |
| Returns the user-preferred size of a window's toolbar icons. | |
| bool | isNonStandardGeoPackageGeometryType (Qgis::WkbType wkbType) |
Returns true if the given wkbType is a non-standard GeoPackage geometry type (PolyhedralSurface, TIN, or Triangle). | |
| bool GUI_EXPORT | openFilesRememberingFilter (QString const &filterName, QString const &filters, QStringList &selectedFiles, QString &enc, QString &title, bool cancelAll=false) |
| Open files, preferring to have the default file selector be the last one used, if any; also, prefer to start in the last directory associated with filterName. | |
| QSize | panelIconSize (QSize size) |
| Returns dockable panel toolbar icon width based on the provided window toolbar width. | |
| bool | restoreGeometry (QWidget *widget, const QString &keyName=QString()) |
| Restore the wigget geometry from settings. | |
| void | saveGeometry (QWidget *widget, const QString &keyName=QString()) |
| Save the wigget geometry into settings. | |
| int | scaleIconSize (int standardSize) |
| Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly, whilst still resulting in pixel-perfect sizes for low-dpi displays. | |
| int | significantDigits (const Qgis::DataType rasterDataType) |
| Returns the maximum number of significant digits a for the given rasterDataType. | |
| bool | warnAboutNonStandardGeoPackageGeometryType (Qgis::WkbType wkbType, QWidget *parent, const QString &dialogTitle, bool showDialog=true, bool *isNonStandard=nullptr) |
| Checks if the given wkbType is a non-standard GeoPackage geometry type (PolyhedralSurface, TIN, or Triangle) and displays a warning message box asking the user if they want to continue. | |
Variables | |
| constexpr double | CANVAS_MAGNIFICATION_MAX = 16.0 |
| Maximum magnification level allowed in map canvases. | |
| constexpr double | CANVAS_MAGNIFICATION_MIN = 0.1 |
| Minimum magnification level allowed in map canvases. | |
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI.
| GUI_EXPORT void QgsGuiUtils::addDockWidget | ( | QMainWindow * | window, |
| Qt::DockWidgetArea | area, | ||
| QDockWidget * | dockwidget ) |
Add a dock widget to a main window.
After adding the dock widget to the UI (by delegating to the QMainWindow parent class, it will also add it to the View menu list of docks, if the window has one.
Definition at line 394 of file qgsguiutils.cpp.
| GUI_EXPORT void QgsGuiUtils::addTabifiedDockWidget | ( | QMainWindow * | window, |
| Qt::DockWidgetArea | area, | ||
| QDockWidget * | dockWidget, | ||
| const QStringList & | tabifyWith = QStringList(), | ||
| bool | raiseTab = false ) |
Add a dock widget to the given area and tabify it (if other dock widgets exist in the same area).
The new tab will be below other tabs unless raiseTab is passed as true.
tabifyWith is a list of dock widget object names, ordered by priority, with which the new dock widget should be tabified. Only the first matching object name will be picked. If none of the given object names is found in that area (or if tabifyWith is not given at all), the new dock widget will be created anyways, but its location within that area will be unpredictable.
Definition at line 412 of file qgsguiutils.cpp.
| QString GUI_EXPORT QgsGuiUtils::createFileFilter_ | ( | QString const & | format | ) |
Create file filters suitable for use with QFileDialog.
| format | extension e.g. "png" |
Definition at line 212 of file qgsguiutils.cpp.
| QString GUI_EXPORT QgsGuiUtils::createFileFilter_ | ( | QString const & | longName, |
| QString const & | glob ) |
Convenience function for readily creating file filters.
Given a long name for a file filter and a regular expression, return a file filter string suitable for use in a QFileDialog::OpenFiles() call. The regular express, glob, will have both all lower and upper case versions added.
Definition at line 207 of file qgsguiutils.cpp.
| QString QgsGuiUtils::createWidgetKey | ( | QWidget * | widget, |
| const QString & | keyName = QString() ) |
Creates a key for the given widget that can be used to store related data in settings.
Will use objectName() or class name if objectName() is not set. Can be overridden using keyName.
| widget | The widget to make the key from. |
| keyName | Override for objectName() if needed. If not set will use objectName() |
Definition at line 249 of file qgsguiutils.cpp.
| QString GUI_EXPORT QgsGuiUtils::displayValueWithMaximumDecimals | ( | const Qgis::DataType | dataType, |
| const double | value, | ||
| bool | displayTrailingZeroes = false ) |
Returns a localized string representation of the value with the appropriate number of decimals supported by the dataType.
Trailing zeroes after decimal separator are not show unless displayTrailingZeroes is set. Note that for floating point types the number of decimals may exceed the actual internal precision because the precision is always calculated on the mantissa and the conversion to string interprets the precision as decimal places.
Definition at line 301 of file qgsguiutils.cpp.
| QFont GUI_EXPORT QgsGuiUtils::getFont | ( | bool & | ok, |
| const QFont & | initial, | ||
| const QString & | title = QString() ) |
Show font selection dialog.
It is strongly recommended that you do not use this method, and instead use the standard QgsFontButton widget to allow users consistent font selection behavior.
| ok | true on ok, false on cancel |
| initial | initial font |
| title | optional dialog title |
Definition at line 219 of file qgsguiutils.cpp.
| QPair< QString, QString > GUI_EXPORT QgsGuiUtils::getSaveAsImageName | ( | QWidget * | parent, |
| const QString & | message, | ||
| const QString & | defaultFilename = QString() ) |
A helper function to get an image name from the user.
It will nicely provide filters with all available writable image formats.
| parent | widget that should act as the parent for the file dialog |
| message | the message to display to the user |
| defaultFilename | default file name (empty by default) |
Definition at line 97 of file qgsguiutils.cpp.
| QSize GUI_EXPORT QgsGuiUtils::iconSize | ( | bool | dockableToolbar = false | ) |
Returns the user-preferred size of a window's toolbar icons.
| dockableToolbar | If set to true, the icon size will be returned for dockable window panel's toolbars. |
Definition at line 273 of file qgsguiutils.cpp.
| bool GUI_EXPORT QgsGuiUtils::isNonStandardGeoPackageGeometryType | ( | Qgis::WkbType | wkbType | ) |
Returns true if the given wkbType is a non-standard GeoPackage geometry type (PolyhedralSurface, TIN, or Triangle).
| wkbType | the geometry type to check |
true if the geometry type is non-standard for GeoPackage Definition at line 355 of file qgsguiutils.cpp.
| bool GUI_EXPORT QgsGuiUtils::openFilesRememberingFilter | ( | QString const & | filterName, |
| QString const & | filters, | ||
| QStringList & | selectedFiles, | ||
| QString & | enc, | ||
| QString & | title, | ||
| bool | cancelAll = false ) |
Open files, preferring to have the default file selector be the last one used, if any; also, prefer to start in the last directory associated with filterName.
| filterName | the name of the filter; used for persistent store key |
| filters | the file filters used for QFileDialog |
| selectedFiles | string list of selected files; will be empty if none selected |
| enc | encoding? |
| title | the title for the dialog |
| cancelAll | add button to cancel further requests |
Opens dialog on last directory associated with the filter name, or the current working directory if this is the first time invoked with the current filter name.
This method returns true if cancel all was clicked, otherwise false
Definition at line 41 of file qgsguiutils.cpp.
| QSize GUI_EXPORT QgsGuiUtils::panelIconSize | ( | QSize | size | ) |
Returns dockable panel toolbar icon width based on the provided window toolbar width.
| size | Icon size from which the output size will be derived from. |
Definition at line 287 of file qgsguiutils.cpp.
| bool GUI_EXPORT QgsGuiUtils::restoreGeometry | ( | QWidget * | widget, |
| const QString & | keyName = QString() ) |
Restore the wigget geometry from settings.
Will use the objectName() of the widget and if empty, or keyName is set, will use keyName to save state into settings.
| widget | The widget to restore. |
| keyName | Override for objectName() if needed. |
true if the geometry was restored. Definition at line 242 of file qgsguiutils.cpp.
| void GUI_EXPORT QgsGuiUtils::saveGeometry | ( | QWidget * | widget, |
| const QString & | keyName = QString() ) |
Save the wigget geometry into settings.
Will use the objectName() of the widget and if empty, or keyName is set, will use keyName to save state into settings.
| widget | The widget to save. |
| keyName | Override for objectName() if needed. |
Definition at line 235 of file qgsguiutils.cpp.
| int GUI_EXPORT QgsGuiUtils::scaleIconSize | ( | int | standardSize | ) |
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly, whilst still resulting in pixel-perfect sizes for low-dpi displays.
standardSize should be set to a standard icon size, e.g. 16, 24, 48, etc.
Definition at line 268 of file qgsguiutils.cpp.
| int GUI_EXPORT QgsGuiUtils::significantDigits | ( | const Qgis::DataType | rasterDataType | ) |
Returns the maximum number of significant digits a for the given rasterDataType.
Definition at line 320 of file qgsguiutils.cpp.
| bool GUI_EXPORT QgsGuiUtils::warnAboutNonStandardGeoPackageGeometryType | ( | Qgis::WkbType | wkbType, |
| QWidget * | parent, | ||
| const QString & | dialogTitle, | ||
| bool | showDialog = true, | ||
| bool * | isNonStandard = nullptr ) |
Checks if the given wkbType is a non-standard GeoPackage geometry type (PolyhedralSurface, TIN, or Triangle) and displays a warning message box asking the user if they want to continue.
| wkbType | the geometry type to check |
| parent | the parent widget for the message box (can be nullptr) |
| dialogTitle | the title for the warning dialog |
| showDialog | if false, the dialog will not be shown and the function will return true for non-standard types (useful for automated testing) |
| isNonStandard | if not nullptr, will be set to true if the geometry type is non-standard for GeoPackage, false otherwise |
true if the geometry type is standard, or if non-standard and the user chose to continue; false if non-standard and the user chose to cancel Definition at line 361 of file qgsguiutils.cpp.
|
constexpr |
Maximum magnification level allowed in map canvases.
Definition at line 71 of file qgsguiutils.h.
|
constexpr |
Minimum magnification level allowed in map canvases.
Definition at line 64 of file qgsguiutils.h.