QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsdialog.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsdialog.cpp
3
-------------------
4
begin : July 2012
5
copyright : (C) 2012 by Etienne Tourigny
6
email : etourigny dot dev at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsdialog.h
"
19
20
#include <QInputDialog>
21
#include <QPlainTextEdit>
22
#include <QSyntaxHighlighter>
23
24
#include "moc_qgsdialog.cpp"
25
26
QgsDialog::QgsDialog
( QWidget *parent, Qt::WindowFlags fl, QDialogButtonBox::StandardButtons buttons, Qt::Orientation orientation )
27
: QDialog( parent, fl )
28
{
29
// create buttonbox
30
mButtonBox
=
new
QDialogButtonBox( buttons, orientation,
this
);
31
connect(
mButtonBox
, &QDialogButtonBox::accepted,
this
, &QDialog::accept );
32
connect(
mButtonBox
, &QDialogButtonBox::rejected,
this
, &QDialog::reject );
33
34
// layout
35
QBoxLayout *
layout
=
nullptr
;
36
if
( orientation == Qt::Horizontal )
37
layout
=
new
QVBoxLayout();
38
else
39
layout
=
new
QHBoxLayout();
40
mLayout
=
new
QVBoxLayout();
41
layout
->addLayout(
mLayout
);
42
layout
->addWidget(
mButtonBox
);
43
setLayout(
layout
);
44
}
45
46
QString
QgsDialog::getMultiLineText
( QWidget *,
const
QString &title,
const
QString &label,
const
QString &text,
bool
*ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints )
47
{
48
auto
dialog = std::make_unique<QInputDialog>(
nullptr
, flags );
49
50
dialog->setOptions( QInputDialog::UsePlainTextEditForTextInput );
51
dialog->setWindowTitle( title );
52
dialog->setLabelText( label );
53
dialog->setTextValue( text );
54
dialog->setInputMethodHints( inputMethodHints );
55
56
if
( QPlainTextEdit *textEdit = dialog->findChild<QPlainTextEdit *>() )
57
{
58
textEdit->setLineWrapMode( QPlainTextEdit::WidgetWidth );
59
}
60
61
const
bool
accepted = dialog->exec() == QDialog::Accepted;
62
63
if
( ok )
64
*ok = accepted;
65
66
if
( accepted )
67
{
68
return
dialog->textValue();
69
}
70
else
71
{
72
return
QString();
73
}
74
}
QgsDialog::getMultiLineText
static QString getMultiLineText(QWidget *parent, const QString &title, const QString &label, const QString &text=QString(), bool *ok=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
Static method to display a multi-line text input dialog with word wrapping.
Definition
qgsdialog.cpp:46
QgsDialog::QgsDialog
QgsDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QDialogButtonBox::StandardButtons buttons=QDialogButtonBox::Close, Qt::Orientation orientation=Qt::Horizontal)
Constructor for QgsDialog.
Definition
qgsdialog.cpp:26
QgsDialog::mButtonBox
QDialogButtonBox * mButtonBox
Definition
qgsdialog.h:69
QgsDialog::layout
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
Definition
qgsdialog.h:48
QgsDialog::mLayout
QVBoxLayout * mLayout
Definition
qgsdialog.h:68
qgsdialog.h
Generated on
for QGIS API Documentation by
1.17.0