QGIS API Documentation  2.99.0-Master (b058df7)
Functions | Variables
QgsGuiUtils Namespace Reference

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

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

Detailed Description

The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI.

Note
not available in Python bindings

Function Documentation

◆ createFileFilter_() [1/2]

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.

◆ createFileFilter_() [2/2]

QString GUI_EXPORT QgsGuiUtils::createFileFilter_ ( QString const &  format)

Create file filters suitable for use with QFileDialog.

Parameters
formatextension e.g. "png"
Returns
QString e.g. "PNG format (*.png, *.PNG)"

Definition at line 185 of file qgsguiutils.cpp.

◆ getFont()

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.

Parameters
oktrue on ok, false on cancel
initialinitial font
titleoptional dialog title
Returns
QFont the selected fon

Definition at line 192 of file qgsguiutils.cpp.

◆ getSaveAsImageName()

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.

Parameters
parentwidget that should act as the parent for the file dialog
messagethe message to display to the user
defaultFilenamedefault file name (empty by default)
Returns
QPair<QString, QString> where first is the file name and second is the file type

Definition at line 87 of file qgsguiutils.cpp.

◆ openFilesRememberingFilter()

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.

Parameters
filterNamethe name of the filter; used for persistent store key
filtersthe file filters used for QFileDialog
selectedFilesstring list of selected files; will be empty if none selected
encencoding?
titlethe title for the dialog
cancelAlladd button to cancel further requests
Note

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.

Variable Documentation

◆ CANVAS_MAGNIFICATION_MAX

constexpr double QgsGuiUtils::CANVAS_MAGNIFICATION_MAX = 16.0

Maximum magnification level allowed in map canvases.

See also
CANVAS_MAGNIFICATION_MAX
Since
QGIS 3.0

Definition at line 69 of file qgsguiutils.h.

◆ CANVAS_MAGNIFICATION_MIN

constexpr double QgsGuiUtils::CANVAS_MAGNIFICATION_MIN = 0.1

Minimum magnification level allowed in map canvases.

See also
CANVAS_MAGNIFICATION_MAX
Since
QGIS 3.0

Definition at line 61 of file qgsguiutils.h.