QGIS API Documentation
3.0.2-Girona (307d082)
|
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI. More...
Functions | |
QString | createFileFilter_ (QString const &longName, QString const &glob) |
Convenience function for readily creating file filters. More... | |
QString | createFileFilter_ (QString const &format) |
Create file filters suitable for use with QFileDialog. More... | |
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. More... | |
QFont | getFont (bool &ok, const QFont &initial, const QString &title=QString()) |
Show font selection dialog. More... | |
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. More... | |
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. More... | |
bool | restoreGeometry (QWidget *widget, const QString &keyName=QString()) |
Restore the wigget geometry from settings. More... | |
void | saveGeometry (QWidget *widget, const QString &keyName=QString()) |
Save the wigget geometry into settings. More... | |
Variables | |
constexpr double | CANVAS_MAGNIFICATION_MAX = 16.0 |
Maximum magnification level allowed in map canvases. More... | |
constexpr double | CANVAS_MAGNIFICATION_MIN = 0.1 |
Minimum magnification level allowed in map canvases. More... | |
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI.
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 180 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 185 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 219 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 192 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 87 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 |
Stores persistent settings under /UI/. The sub-keys will be filterName and filterName + "Dir".
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 29 of file qgsguiutils.cpp.
bool GUI_EXPORT QgsGuiUtils::restoreGeometry | ( | QWidget * | widget, |
const QString & | keyName = QString() |
||
) |
Restore the wigget geometry from settings.
Will use the objetName() 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. |
Definition at line 212 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 205 of file qgsguiutils.cpp.
constexpr double QgsGuiUtils::CANVAS_MAGNIFICATION_MAX = 16.0 |
Maximum magnification level allowed in map canvases.
Definition at line 69 of file qgsguiutils.h.
constexpr double QgsGuiUtils::CANVAS_MAGNIFICATION_MIN = 0.1 |
Minimum magnification level allowed in map canvases.
Definition at line 61 of file qgsguiutils.h.