QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Functions | Variables
QgisGui Namespace Reference

/namespace QgisGui The QgisGui 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 *theParent, const QString &theMessage, const QString &defaultFilename=QString::null)
 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

static const double CANVAS_MAGNIFICATION_MAX = 16.0
 Maximum magnification level allowed in map canvases. More...
 
static const double CANVAS_MAGNIFICATION_MIN = 0.1
 Minimum magnification level allowed in map canvases. More...
 
static const Qt::WindowFlags ModalDialogFlags = nullptr
 

Detailed Description

/namespace QgisGui The QgisGui 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 QgisGui::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 179 of file qgisgui.cpp.

◆ createFileFilter_() [2/2]

QString GUI_EXPORT QgisGui::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 184 of file qgisgui.cpp.

◆ getFont()

QFont GUI_EXPORT QgisGui::getFont ( bool &  ok,
const QFont initial,
const QString title = QString() 
)

Show font selection dialog.

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

Definition at line 191 of file qgisgui.cpp.

◆ getSaveAsImageName()

QPair< QString, QString > GUI_EXPORT QgisGui::getSaveAsImageName ( QWidget theParent,
const QString theMessage,
const QString defaultFilename = QString::null 
)

A helper function to get an image name from the user.

It will nicely provide filters with all available writable image formats.

Parameters
theParentwidget that should act as the parent for the file dialog
theMessagethe 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 86 of file qgisgui.cpp.

◆ openFilesRememberingFilter()

bool GUI_EXPORT QgisGui::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 28 of file qgisgui.cpp.

Variable Documentation

◆ CANVAS_MAGNIFICATION_MAX

const double QgisGui::CANVAS_MAGNIFICATION_MAX = 16.0
static

Maximum magnification level allowed in map canvases.

See also
CANVAS_MAGNIFICATION_MAX
Note
added in QGIS 2.18

Definition at line 65 of file qgisgui.h.

◆ CANVAS_MAGNIFICATION_MIN

const double QgisGui::CANVAS_MAGNIFICATION_MIN = 0.1
static

Minimum magnification level allowed in map canvases.

See also
CANVAS_MAGNIFICATION_MAX
Note
added in QGIS 2.18

Definition at line 57 of file qgisgui.h.

◆ ModalDialogFlags

const Qt::WindowFlags QgisGui::ModalDialogFlags = nullptr
static

/var ModalDialogFlags /brief Flags used to create a modal dialog (adapted from QMessageBox).

Using these flags for all modal dialogs throughout QGIS ensures that for platforms such as the Mac where modal and modeless dialogs have different looks, QGIS modal dialogs will look the same as Qt modal dialogs and all modal dialogs will look distinct from modeless dialogs. Althought not the standard Mac modal look, it does lack the minimize control which makes sense only for modeless dislogs.

The Qt3 method of creating a true Mac modal dialog is deprecated in Qt4 and should not be used due to conflicts with QMessageBox style dialogs.

Qt::WindowMaximizeButtonHint is included but will be ignored if the dialog is a fixed size and does not have a size grip.

Definition at line 50 of file qgisgui.h.