Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
propertylineedit.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
// Qt-Security score:significant reason:default
4
5
#
include
"propertylineedit_p.h"
6
7
#
include
<
QtGui
/
qevent
.
h
>
8
#
include
<
QtWidgets
/
qmenu
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
using
namespace
Qt::StringLiterals;
13
14
namespace
qdesigner_internal
{
15
PropertyLineEdit
::PropertyLineEdit(QWidget *parent) :
16
QLineEdit(parent), m_wantNewLine(
false
)
17
{
18
}
19
20
bool
PropertyLineEdit
::
event
(QEvent *e)
21
{
22
// handle 'Select all' here as it is not done in the QLineEdit
23
if
(e->type() == QEvent::ShortcutOverride && !isReadOnly()) {
24
QKeyEvent* ke =
static_cast
<QKeyEvent*> (e);
25
if
(ke->modifiers() & Qt::ControlModifier) {
26
if
(ke->key() == Qt::Key_A) {
27
ke->accept();
28
return
true
;
29
}
30
}
31
}
32
return
QLineEdit::event(e);
33
}
34
35
void
PropertyLineEdit
::insertNewLine() {
36
insertText(u"\\n"_s);
37
}
38
39
void
PropertyLineEdit
::insertText(
const
QString &text) {
40
// position cursor after new text and grab focus
41
const
int
oldCursorPosition = cursorPosition ();
42
insert(text);
43
setCursorPosition (oldCursorPosition + text.size());
44
setFocus(Qt::OtherFocusReason);
45
}
46
47
void
PropertyLineEdit
::
contextMenuEvent
(QContextMenuEvent *event) {
48
QMenu *menu = createStandardContextMenu ();
49
50
if
(m_wantNewLine) {
51
menu->addSeparator();
52
menu->addAction(tr(
"Insert line break"
),
this
, &PropertyLineEdit::insertNewLine);
53
}
54
55
menu->exec(event->globalPos());
56
}
57
}
58
59
QT_END_NAMESPACE
qdesigner_internal::PropertyLineEdit
Definition
propertylineedit_p.h:28
qdesigner_internal::PropertyLineEdit::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *event) override
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition
propertylineedit.cpp:47
qdesigner_internal::PropertyLineEdit::event
bool event(QEvent *e) override
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition
propertylineedit.cpp:20
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
qttools
src
designer
src
lib
shared
propertylineedit.cpp
Generated on
for Qt by
1.18.0