Qt 4.8
qtextedit.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qtextedit_p.h"
43 #include "qlineedit.h"
44 #include "qtextbrowser.h"
45 
46 #ifndef QT_NO_TEXTEDIT
47 #include <qfont.h>
48 #include <qpainter.h>
49 #include <qevent.h>
50 #include <qdebug.h>
51 #include <qmime.h>
52 #include <qdrag.h>
53 #include <qclipboard.h>
54 #include <qmenu.h>
55 #include <qstyle.h>
56 #include <qtimer.h>
57 #include "private/qtextdocumentlayout_p.h"
58 #include "qtextdocument.h"
59 #include "private/qtextdocument_p.h"
60 #include "qtextlist.h"
61 #include "private/qtextcontrol_p.h"
62 
63 #include <qtextformat.h>
64 #include <qdatetime.h>
65 #include <qapplication.h>
66 #include <limits.h>
67 #include <qtexttable.h>
68 #include <qvariant.h>
69 
70 #include <qinputcontext.h>
71 #endif
72 
74 
75 
76 #ifndef QT_NO_TEXTEDIT
77 static inline bool shouldEnableInputMethod(QTextEdit *textedit)
78 {
79  return !textedit->isReadOnly();
80 }
81 
83 {
84 public:
86 
89  if (!ed)
91  return ed->createMimeDataFromSelection();
92  }
93  virtual bool canInsertFromMimeData(const QMimeData *source) const {
95  if (!ed)
97  return ed->canInsertFromMimeData(source);
98  }
99  virtual void insertFromMimeData(const QMimeData *source) {
101  if (!ed)
103  else
104  ed->insertFromMimeData(source);
105  }
106 };
107 
109  : control(0),
110  autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false),
111  lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0),
112  wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), clickCausedFocus(0),
113  textFormat(Qt::AutoText)
114 {
116  preferRichText = false;
118  inDrag = false;
119 }
120 
122 {
123  QTextCursor cursor = control->textCursor();
124  cursor.beginEditBlock();
125 
126  QTextBlockFormat blockFmt = cursor.blockFormat();
127 
128  QTextListFormat listFmt;
130  listFmt.setIndent(blockFmt.indent() + 1);
131 
132  blockFmt.setIndent(0);
133  cursor.setBlockFormat(blockFmt);
134 
135  cursor.createList(listFmt);
136 
137  cursor.endEditBlock();
138  control->setTextCursor(cursor);
139 }
140 
142 {
143  Q_Q(QTextEdit);
144  control = new QTextEditControl(q);
145  control->setPalette(q->palette());
146 
147  QObject::connect(control, SIGNAL(microFocusChanged()), q, SLOT(updateMicroFocus()));
148  QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)), q, SLOT(_q_adjustScrollbars()));
150  QObject::connect(control, SIGNAL(visibilityRequest(QRectF)), q, SLOT(_q_ensureVisible(QRectF)));
151  QObject::connect(control, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
153 
154  QObject::connect(control, SIGNAL(textChanged()), q, SIGNAL(textChanged()));
155  QObject::connect(control, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
156  QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
157  QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool)));
158  QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
159  QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
160 
161  QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
162 
163  QTextDocument *doc = control->document();
164  // set a null page size initially to avoid any relayouting until the textedit
165  // is shown. relayoutDocument() will take care of setting the page size to the
166  // viewport dimensions later.
167  doc->setPageSize(QSize(0, 0));
169  doc->setDefaultFont(q->font());
170  doc->setUndoRedoEnabled(false); // flush undo buffer.
171  doc->setUndoRedoEnabled(true);
172 
173  if (!html.isEmpty())
174  control->setHtml(html);
175 
176  hbar->setSingleStep(20);
177  vbar->setSingleStep(20);
178 
180  q->setAcceptDrops(true);
181  q->setFocusPolicy(Qt::WheelFocus);
182  q->setAttribute(Qt::WA_KeyCompression);
183  q->setAttribute(Qt::WA_InputMethodEnabled);
184 
185 #ifndef QT_NO_CURSOR
187 #endif
188 #ifdef Q_WS_WIN
190 #endif
191 }
192 
194 {
195  if (!contentsRect.isValid()) {
196  viewport->update();
197  return;
198  }
199  const int xOffset = horizontalOffset();
200  const int yOffset = verticalOffset();
201  const QRectF visibleRect(xOffset, yOffset, viewport->width(), viewport->height());
202 
203  QRect r = contentsRect.intersected(visibleRect).toAlignedRect();
204  if (r.isEmpty())
205  return;
206 
207  r.translate(-xOffset, -yOffset);
208  viewport->update(r);
209 }
210 
212 {
213  QTextCursor cursor = control->textCursor();
214  bool moved = false;
215  qreal lastY = control->cursorRect(cursor).top();
216  qreal distance = 0;
217  // move using movePosition to keep the cursor's x
218  do {
219  qreal y = control->cursorRect(cursor).top();
220  distance += qAbs(y - lastY);
221  lastY = y;
222  moved = cursor.movePosition(op, moveMode);
223  } while (moved && distance < viewport->height());
224 
225  if (moved) {
226  if (op == QTextCursor::Up) {
227  cursor.movePosition(QTextCursor::Down, moveMode);
229  } else {
230  cursor.movePosition(QTextCursor::Up, moveMode);
232  }
233  }
234  control->setTextCursor(cursor);
235 }
236 
237 #ifndef QT_NO_SCROLLBAR
239 {
240  QTextDocument *doc = control->document();
242 
243  QSize docSize;
244 
245  if (QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout)) {
246  docSize = tlayout->dynamicDocumentSize().toSize();
247  int percentageDone = tlayout->layoutStatus();
248  // extrapolate height
249  if (percentageDone > 0)
250  docSize.setHeight(docSize.height() * 100 / percentageDone);
251  } else {
252  docSize = layout->documentSize().toSize();
253  }
254 
255  return docSize;
256 }
257 
259 {
261  return;
262  ignoreAutomaticScrollbarAdjustment = true; // avoid recursion, #106108
263 
264  QSize viewportSize = viewport->size();
265  QSize docSize = documentSize(control);
266 
267  // due to the recursion guard we have to repeat this step a few times,
268  // as adding/removing a scroll bar will cause the document or viewport
269  // size to change
270  // ideally we should loop until the viewport size and doc size stabilize,
271  // but in corner cases they might fluctuate, so we need to limit the
272  // number of iterations
273  for (int i = 0; i < 4; ++i) {
274  hbar->setRange(0, docSize.width() - viewportSize.width());
275  hbar->setPageStep(viewportSize.width());
276 
277  vbar->setRange(0, docSize.height() - viewportSize.height());
278  vbar->setPageStep(viewportSize.height());
279 
280  // if we are in left-to-right mode widening the document due to
281  // lazy layouting does not require a repaint. If in right-to-left
282  // the scroll bar has the value zero and it visually has the maximum
283  // value (it is visually at the right), then widening the document
284  // keeps it at value zero but visually adjusts it to the new maximum
285  // on the right, hence we need an update.
286  if (q_func()->isRightToLeft())
287  viewport->update();
288 
290 
291  const QSize oldViewportSize = viewportSize;
292  const QSize oldDocSize = docSize;
293 
294  // make sure the document is layouted if the viewport width changes
295  viewportSize = viewport->size();
296  if (viewportSize.width() != oldViewportSize.width())
298 
299  docSize = documentSize(control);
300  if (viewportSize == oldViewportSize && docSize == oldDocSize)
301  break;
302  }
304 }
305 #endif
306 
307 // rect is in content coordinates
309 {
310  const QRect rect = _rect.toRect();
311  if ((vbar->isVisible() && vbar->maximum() < rect.bottom())
312  || (hbar->isVisible() && hbar->maximum() < rect.right()))
314  const int visibleWidth = viewport->width();
315  const int visibleHeight = viewport->height();
316  const bool rtl = q_func()->isRightToLeft();
317 
318  if (rect.x() < horizontalOffset()) {
319  if (rtl)
320  hbar->setValue(hbar->maximum() - rect.x());
321  else
322  hbar->setValue(rect.x());
323  } else if (rect.x() + rect.width() > horizontalOffset() + visibleWidth) {
324  if (rtl)
325  hbar->setValue(hbar->maximum() - (rect.x() + rect.width() - visibleWidth));
326  else
327  hbar->setValue(rect.x() + rect.width() - visibleWidth);
328  }
329 
330  if (rect.y() < verticalOffset())
331  vbar->setValue(rect.y());
332  else if (rect.y() + rect.height() > verticalOffset() + visibleHeight)
333  vbar->setValue(rect.y() + rect.height() - visibleHeight);
334 }
335 
581 #ifdef QT3_SUPPORT
582 
602 #endif
603 
609  : QAbstractScrollArea(*new QTextEditPrivate, parent)
610 {
611  Q_D(QTextEdit);
612  d->init();
613 }
614 
619  : QAbstractScrollArea(dd, parent)
620 {
621  Q_D(QTextEdit);
622  d->init();
623 }
624 
630  : QAbstractScrollArea(*new QTextEditPrivate, parent)
631 {
632  Q_D(QTextEdit);
633  d->init(text);
634 }
635 
636 #ifdef QT3_SUPPORT
637 
642  : QAbstractScrollArea(*new QTextEditPrivate, parent)
643 {
644  Q_D(QTextEdit);
645  d->init();
647 }
648 #endif
649 
650 
655 {
656 }
657 
664 {
665  Q_D(const QTextEdit);
666  return d->control->textCursor().charFormat().fontPointSize();
667 }
668 
675 {
676  Q_D(const QTextEdit);
677  return d->control->textCursor().charFormat().fontFamily();
678 }
679 
686 {
687  Q_D(const QTextEdit);
688  return d->control->textCursor().charFormat().fontWeight();
689 }
690 
698 {
699  Q_D(const QTextEdit);
700  return d->control->textCursor().charFormat().fontUnderline();
701 }
702 
710 {
711  Q_D(const QTextEdit);
712  return d->control->textCursor().charFormat().fontItalic();
713 }
714 
721 {
722  Q_D(const QTextEdit);
723  return d->control->textCursor().charFormat().foreground().color();
724 }
725 
737 {
738  Q_D(const QTextEdit);
739  return d->control->textCursor().charFormat().background().color();
740 }
741 
748 {
749  Q_D(const QTextEdit);
750  return d->control->textCursor().charFormat().font();
751 }
752 
759 void QTextEdit::setAlignment(Qt::Alignment a)
760 {
761  Q_D(QTextEdit);
762  QTextBlockFormat fmt;
763  fmt.setAlignment(a);
764  QTextCursor cursor = d->control->textCursor();
765  cursor.mergeBlockFormat(fmt);
766  d->control->setTextCursor(cursor);
767 }
768 
774 Qt::Alignment QTextEdit::alignment() const
775 {
776  Q_D(const QTextEdit);
777  return d->control->textCursor().blockFormat().alignment();
778 }
779 
792 {
793  Q_D(QTextEdit);
794  d->control->setDocument(document);
795  d->updateDefaultTextOption();
796  d->relayoutDocument();
797 }
798 
805 {
806  Q_D(const QTextEdit);
807  return d->control->document();
808 }
809 
814 {
815  Q_D(QTextEdit);
816  d->control->setTextCursor(cursor);
817 }
818 
825 {
826  Q_D(const QTextEdit);
827  return d->control->textCursor();
828 }
829 
836 {
837  QTextCharFormat fmt;
838  fmt.setFontFamily(fontFamily);
840 }
841 
851 {
852  QTextCharFormat fmt;
853  fmt.setFontPointSize(s);
855 }
856 
870 {
871  QTextCharFormat fmt;
872  fmt.setFontWeight(w);
874 }
875 
882 void QTextEdit::setFontUnderline(bool underline)
883 {
884  QTextCharFormat fmt;
885  fmt.setFontUnderline(underline);
887 }
888 
895 void QTextEdit::setFontItalic(bool italic)
896 {
897  QTextCharFormat fmt;
898  fmt.setFontItalic(italic);
900 }
901 
908 {
909  QTextCharFormat fmt;
910  fmt.setForeground(QBrush(c));
912 }
913 
925 {
926  QTextCharFormat fmt;
927  fmt.setBackground(QBrush(c));
929 }
930 
937 {
938  QTextCharFormat fmt;
939  fmt.setFont(f);
941 }
942 
957 {
958  Q_D(QTextEdit);
959  d->control->undo();
960 }
961 
963 {
964  Q_D(QTextEdit);
965  d->control->redo();
966 }
967 
994 #ifndef QT_NO_CLIPBOARD
995 
1005 {
1006  Q_D(QTextEdit);
1007  d->control->cut();
1008 }
1009 
1017 {
1018  Q_D(QTextEdit);
1019  d->control->copy();
1020 }
1021 
1037 {
1038  Q_D(QTextEdit);
1039  d->control->paste();
1040 }
1041 #endif
1042 
1051 {
1052  Q_D(QTextEdit);
1053  // clears and sets empty content
1054  d->control->clear();
1055 }
1056 
1057 
1064 {
1065  Q_D(QTextEdit);
1066  d->control->selectAll();
1067 }
1068 
1072 {
1073  Q_D(QTextEdit);
1074 #ifndef QT_NO_CONTEXTMENU
1075  if (e->type() == QEvent::ContextMenu
1076  && static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard) {
1077  Q_D(QTextEdit);
1079  const QPoint cursorPos = cursorRect().center();
1080  QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos));
1081  ce.setAccepted(e->isAccepted());
1082  const bool result = QAbstractScrollArea::event(&ce);
1083  e->setAccepted(ce.isAccepted());
1084  return result;
1085  } else if (e->type() == QEvent::ShortcutOverride
1086  || e->type() == QEvent::ToolTip) {
1087  d->sendControlEvent(e);
1088  }
1089 #endif // QT_NO_CONTEXTMENU
1090 #ifdef QT_KEYPAD_NAVIGATION
1091  if (e->type() == QEvent::EnterEditFocus || e->type() == QEvent::LeaveEditFocus) {
1092  if (QApplication::keypadNavigationEnabled())
1093  d->sendControlEvent(e);
1094  }
1095 #endif
1096  return QAbstractScrollArea::event(e);
1097 }
1098 
1103 {
1104  Q_D(QTextEdit);
1105  if (e->timerId() == d->autoScrollTimer.timerId()) {
1106  QRect visible = d->viewport->rect();
1107  QPoint pos;
1108  if (d->inDrag) {
1109  pos = d->autoScrollDragPos;
1110  visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20),
1111  -qMin(visible.width()/3,20), -qMin(visible.height()/3,20));
1112  } else {
1113  const QPoint globalPos = QCursor::pos();
1114  pos = d->viewport->mapFromGlobal(globalPos);
1116  mouseMoveEvent(&ev);
1117  }
1118  int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height();
1119  int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width();
1120  int delta = qMax(deltaX, deltaY);
1121  if (delta >= 0) {
1122  if (delta < 7)
1123  delta = 7;
1124  int timeout = 4900 / (delta * delta);
1125  d->autoScrollTimer.start(timeout, this);
1126 
1127  if (deltaY > 0)
1128  d->vbar->triggerAction(pos.y() < visible.center().y() ?
1131  if (deltaX > 0)
1132  d->hbar->triggerAction(pos.x() < visible.center().x() ?
1135  }
1136  }
1137 #ifdef QT_KEYPAD_NAVIGATION
1138  else if (e->timerId() == d->deleteAllTimer.timerId()) {
1139  d->deleteAllTimer.stop();
1140  clear();
1141  }
1142 #endif
1143 }
1144 
1157 {
1158  Q_D(QTextEdit);
1159  d->control->setPlainText(text);
1160  d->preferRichText = false;
1161 }
1162 
1199 #ifndef QT_NO_TEXTHTMLPARSER
1201 {
1202  Q_D(QTextEdit);
1203  d->control->setHtml(text);
1204  d->preferRichText = true;
1205 }
1206 #endif
1207 
1211 {
1212  Q_D(QTextEdit);
1213 
1214 #ifdef QT_KEYPAD_NAVIGATION
1215  switch (e->key()) {
1216  case Qt::Key_Select:
1217  if (QApplication::keypadNavigationEnabled()) {
1218  // code assumes linksaccessible + editable isn't meaningful
1219  if (d->control->textInteractionFlags() & Qt::TextEditable) {
1220  setEditFocus(!hasEditFocus());
1221  } else {
1222  if (!hasEditFocus())
1223  setEditFocus(true);
1224  else {
1225  QTextCursor cursor = d->control->textCursor();
1226  QTextCharFormat charFmt = cursor.charFormat();
1227  if (!(d->control->textInteractionFlags() & Qt::LinksAccessibleByKeyboard)
1228  || !cursor.hasSelection() || charFmt.anchorHref().isEmpty()) {
1229  e->accept();
1230  return;
1231  }
1232  }
1233  }
1234  }
1235  break;
1236  case Qt::Key_Back:
1237  case Qt::Key_No:
1238  if (!QApplication::keypadNavigationEnabled()
1239  || (QApplication::keypadNavigationEnabled() && !hasEditFocus())) {
1240  e->ignore();
1241  return;
1242  }
1243  break;
1244  default:
1245  if (QApplication::keypadNavigationEnabled()) {
1246  if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) {
1247  if (e->text()[0].isPrint())
1248  setEditFocus(true);
1249  else {
1250  e->ignore();
1251  return;
1252  }
1253  }
1254  }
1255  break;
1256  }
1257 #endif
1258 #ifndef QT_NO_SHORTCUT
1259 
1260  Qt::TextInteractionFlags tif = d->control->textInteractionFlags();
1261 
1262  if (tif & Qt::TextSelectableByKeyboard){
1264  e->accept();
1266  return;
1267  } else if (e ==QKeySequence::SelectNextPage) {
1268  e->accept();
1270  return;
1271  }
1272  }
1273  if (tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable)) {
1275  e->accept();
1277  return;
1278  } else if (e == QKeySequence::MoveToNextPage) {
1279  e->accept();
1281  return;
1282  }
1283  }
1284 
1285  if (!(tif & Qt::TextEditable)) {
1286  switch (e->key()) {
1287  case Qt::Key_Space:
1288  e->accept();
1289  if (e->modifiers() & Qt::ShiftModifier)
1290  d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub);
1291  else
1292  d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd);
1293  break;
1294  default:
1295  d->sendControlEvent(e);
1296  if (!e->isAccepted() && e->modifiers() == Qt::NoModifier) {
1297  if (e->key() == Qt::Key_Home) {
1298  d->vbar->triggerAction(QAbstractSlider::SliderToMinimum);
1299  e->accept();
1300  } else if (e->key() == Qt::Key_End) {
1301  d->vbar->triggerAction(QAbstractSlider::SliderToMaximum);
1302  e->accept();
1303  }
1304  }
1305  if (!e->isAccepted()) {
1307  }
1308  }
1309  return;
1310  }
1311 #endif // QT_NO_SHORTCUT
1312 
1313  {
1314  QTextCursor cursor = d->control->textCursor();
1315  const QString text = e->text();
1316  if (cursor.atBlockStart()
1317  && (d->autoFormatting & AutoBulletList)
1318  && (text.length() == 1)
1319  && (text.at(0) == QLatin1Char('-') || text.at(0) == QLatin1Char('*'))
1320  && (!cursor.currentList())) {
1321 
1322  d->createAutoBulletList();
1323  e->accept();
1324  return;
1325  }
1326  }
1327 
1328  d->sendControlEvent(e);
1329 #ifdef QT_KEYPAD_NAVIGATION
1330  if (!e->isAccepted()) {
1331  switch (e->key()) {
1332  case Qt::Key_Up:
1333  case Qt::Key_Down:
1334  if (QApplication::keypadNavigationEnabled()) {
1335  // Cursor position didn't change, so we want to leave
1336  // these keys to change focus.
1337  e->ignore();
1338  return;
1339  }
1340  break;
1341  case Qt::Key_Back:
1342  if (!e->isAutoRepeat()) {
1343  if (QApplication::keypadNavigationEnabled()) {
1344  if (document()->isEmpty() || !(d->control->textInteractionFlags() & Qt::TextEditable)) {
1345  setEditFocus(false);
1346  e->accept();
1347  } else if (!d->deleteAllTimer.isActive()) {
1348  e->accept();
1349  d->deleteAllTimer.start(750, this);
1350  }
1351  } else {
1352  e->ignore();
1353  return;
1354  }
1355  }
1356  break;
1357  default: break;
1358  }
1359  }
1360 #endif
1361 }
1362 
1366 {
1367 #ifdef QT_KEYPAD_NAVIGATION
1368  Q_D(QTextEdit);
1369  if (QApplication::keypadNavigationEnabled()) {
1370  if (!e->isAutoRepeat() && e->key() == Qt::Key_Back
1371  && d->deleteAllTimer.isActive()) {
1372  d->deleteAllTimer.stop();
1373  QTextCursor cursor = d->control->textCursor();
1374  QTextBlockFormat blockFmt = cursor.blockFormat();
1375 
1376  QTextList *list = cursor.currentList();
1377  if (list && cursor.atBlockStart()) {
1378  list->remove(cursor.block());
1379  } else if (cursor.atBlockStart() && blockFmt.indent() > 0) {
1380  blockFmt.setIndent(blockFmt.indent() - 1);
1381  cursor.setBlockFormat(blockFmt);
1382  } else {
1383  cursor.deletePreviousChar();
1384  }
1385  setTextCursor(cursor);
1386  e->accept();
1387  return;
1388  }
1389  }
1390 #endif
1391  e->ignore();
1392 }
1393 
1402 {
1403  Q_UNUSED(type);
1404  Q_UNUSED(name);
1405  return QVariant();
1406 }
1407 
1411 {
1412  Q_D(QTextEdit);
1413 
1414  if (d->lineWrap == NoWrap) {
1415  QTextDocument *doc = d->control->document();
1416  QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
1417 
1418  if (!doc->pageSize().isNull()
1419  && alignmentProperty.type() == QVariant::Bool
1420  && !alignmentProperty.toBool()) {
1421 
1422  d->_q_adjustScrollbars();
1423  return;
1424  }
1425  }
1426 
1427  if (d->lineWrap != FixedPixelWidth
1428  && e->oldSize().width() != e->size().width())
1429  d->relayoutDocument();
1430  else
1431  d->_q_adjustScrollbars();
1432 }
1433 
1435 {
1436  QTextDocument *doc = control->document();
1438 
1439  if (QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout)) {
1440  if (lineWrap == QTextEdit::FixedColumnWidth)
1441  tlayout->setFixedColumnWidth(lineWrapColumnOrWidth);
1442  else
1443  tlayout->setFixedColumnWidth(-1);
1444  }
1445 
1447  QSize lastUsedSize;
1448  if (tlayout)
1449  lastUsedSize = tlayout->dynamicDocumentSize().toSize();
1450  else
1451  lastUsedSize = layout->documentSize().toSize();
1452 
1453  // ignore calls to _q_adjustScrollbars caused by an emission of the
1454  // usedSizeChanged() signal in the layout, as we're calling it
1455  // later on our own anyway (or deliberately not) .
1456  const bool oldIgnoreScrollbarAdjustment = ignoreAutomaticScrollbarAdjustment;
1457  ignoreAutomaticScrollbarAdjustment = true;
1458 
1459  int width = viewport->width();
1460  if (lineWrap == QTextEdit::FixedPixelWidth)
1461  width = lineWrapColumnOrWidth;
1462  else if (lineWrap == QTextEdit::NoWrap) {
1463  QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
1464  if (alignmentProperty.type() == QVariant::Bool && !alignmentProperty.toBool()) {
1465 
1466  width = 0;
1467  }
1468  }
1469 
1470  doc->setPageSize(QSize(width, -1));
1471  if (tlayout)
1472  tlayout->ensureLayouted(verticalOffset() + viewport->height());
1473 
1474  ignoreAutomaticScrollbarAdjustment = oldIgnoreScrollbarAdjustment;
1475 
1476  QSize usedSize;
1477  if (tlayout)
1478  usedSize = tlayout->dynamicDocumentSize().toSize();
1479  else
1480  usedSize = layout->documentSize().toSize();
1481 
1482  // this is an obscure situation in the layout that can happen:
1483  // if a character at the end of a line is the tallest one and therefore
1484  // influencing the total height of the line and the line right below it
1485  // is always taller though, then it can happen that if due to line breaking
1486  // that tall character wraps into the lower line the document not only shrinks
1487  // horizontally (causing the character to wrap in the first place) but also
1488  // vertically, because the original line is now smaller and the one below kept
1489  // its size. So a layout with less width _can_ take up less vertical space, too.
1490  // If the wider case causes a vertical scroll bar to appear and the narrower one
1491  // (narrower because the vertical scroll bar takes up horizontal space)) to disappear
1492  // again then we have an endless loop, as _q_adjustScrollBars sets new ranges on the
1493  // scroll bars, the QAbstractScrollArea will find out about it and try to show/hide
1494  // the scroll bars again. That's why we try to detect this case here and break out.
1495  //
1496  // (if you change this please also check the layoutingLoop() testcase in
1497  // QTextEdit's autotests)
1498  if (lastUsedSize.isValid()
1499  && !vbar->isHidden()
1500  && viewport->width() < lastUsedSize.width()
1501  && usedSize.height() < lastUsedSize.height()
1502  && usedSize.height() <= viewport->height())
1503  return;
1504 
1505  _q_adjustScrollbars();
1506 }
1507 
1509 {
1510  const int xOffset = horizontalOffset();
1511  const int yOffset = verticalOffset();
1512 
1513  QRect r = e->rect();
1514  p->translate(-xOffset, -yOffset);
1515  r.translate(xOffset, yOffset);
1516 
1517  QTextDocument *doc = control->document();
1519 
1520  // the layout might need to expand the root frame to
1521  // the viewport if NoWrap is set
1522  if (layout)
1523  layout->setViewport(viewport->rect());
1524 
1525  control->drawContents(p, r, q_func());
1526 
1527  if (layout)
1528  layout->setViewport(QRect());
1529 }
1530 
1540 {
1541  Q_D(QTextEdit);
1542  QPainter p(d->viewport);
1543  d->paint(&p, e);
1544 }
1545 
1547 {
1548  Q_Q(QTextEdit);
1549  emit q->currentCharFormatChanged(fmt);
1550 #ifdef QT3_SUPPORT
1551  // compat signals
1552  emit q->currentFontChanged(fmt.font());
1553  emit q->currentColorChanged(fmt.foreground().color());
1554 #endif
1555 }
1556 
1558 {
1559  QTextDocument *doc = control->document();
1560 
1561  QTextOption opt = doc->defaultTextOption();
1562  QTextOption::WrapMode oldWrapMode = opt.wrapMode();
1563 
1564  if (lineWrap == QTextEdit::NoWrap)
1566  else
1567  opt.setWrapMode(wordWrap);
1568 
1569  if (opt.wrapMode() != oldWrapMode)
1570  doc->setDefaultTextOption(opt);
1571 }
1572 
1576 {
1577  Q_D(QTextEdit);
1578 #ifdef QT_KEYPAD_NAVIGATION
1579  if (QApplication::keypadNavigationEnabled() && !hasEditFocus())
1580  setEditFocus(true);
1581 #endif
1582  d->sendControlEvent(e);
1583 }
1584 
1588 {
1589  Q_D(QTextEdit);
1590  d->inDrag = false; // paranoia
1591  const QPoint pos = e->pos();
1592  d->sendControlEvent(e);
1593  if (!(e->buttons() & Qt::LeftButton))
1594  return;
1595  QRect visible = d->viewport->rect();
1596  if (visible.contains(pos))
1597  d->autoScrollTimer.stop();
1598  else if (!d->autoScrollTimer.isActive())
1599  d->autoScrollTimer.start(100, this);
1600 }
1601 
1605 {
1606  Q_D(QTextEdit);
1607  d->sendControlEvent(e);
1608  if (d->autoScrollTimer.isActive()) {
1609  d->autoScrollTimer.stop();
1611  }
1612  if (!isReadOnly() && rect().contains(e->pos()))
1613  d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
1614  d->clickCausedFocus = 0;
1615 }
1616 
1620 {
1621  Q_D(QTextEdit);
1622  d->sendControlEvent(e);
1623 }
1624 
1628 {
1629  Q_D(const QTextEdit);
1630  if (!d->tabChangesFocus && d->control->textInteractionFlags() & Qt::TextEditable)
1631  return false;
1633 }
1634 
1635 #ifndef QT_NO_CONTEXTMENU
1636 
1652 {
1653  Q_D(QTextEdit);
1654  d->sendControlEvent(e);
1655 }
1656 #endif // QT_NO_CONTEXTMENU
1657 
1658 #ifndef QT_NO_DRAGANDDROP
1659 
1662 {
1663  Q_D(QTextEdit);
1664  d->inDrag = true;
1665  d->sendControlEvent(e);
1666 }
1667 
1671 {
1672  Q_D(QTextEdit);
1673  d->inDrag = false;
1674  d->autoScrollTimer.stop();
1675  d->sendControlEvent(e);
1676 }
1677 
1681 {
1682  Q_D(QTextEdit);
1683  d->autoScrollDragPos = e->pos();
1684  if (!d->autoScrollTimer.isActive())
1685  d->autoScrollTimer.start(100, this);
1686  d->sendControlEvent(e);
1687 }
1688 
1692 {
1693  Q_D(QTextEdit);
1694  d->inDrag = false;
1695  d->autoScrollTimer.stop();
1696  d->sendControlEvent(e);
1697 }
1698 
1699 #endif // QT_NO_DRAGANDDROP
1700 
1704 {
1705  Q_D(QTextEdit);
1706 #ifdef QT_KEYPAD_NAVIGATION
1707  if (d->control->textInteractionFlags() & Qt::TextEditable
1708  && QApplication::keypadNavigationEnabled()
1709  && !hasEditFocus())
1710  setEditFocus(true);
1711 #endif
1712  d->sendControlEvent(e);
1714 }
1715 
1718 void QTextEdit::scrollContentsBy(int dx, int dy)
1719 {
1720  Q_D(QTextEdit);
1721  if (isRightToLeft())
1722  dx = -dx;
1723  d->viewport->scroll(dx, dy);
1724 }
1725 
1729 {
1730  Q_D(const QTextEdit);
1731  QVariant v = d->control->inputMethodQuery(property);
1732  const QPoint offset(-d->horizontalOffset(), -d->verticalOffset());
1733  if (v.type() == QVariant::RectF)
1734  v = v.toRectF().toRect().translated(offset);
1735  else if (v.type() == QVariant::PointF)
1736  v = v.toPointF().toPoint() + offset;
1737  else if (v.type() == QVariant::Rect)
1738  v = v.toRect().translated(offset);
1739  else if (v.type() == QVariant::Point)
1740  v = v.toPoint() + offset;
1741  return v;
1742 }
1743 
1747 {
1748  Q_D(QTextEdit);
1749  if (e->reason() == Qt::MouseFocusReason) {
1750  d->clickCausedFocus = 1;
1751  }
1753  d->sendControlEvent(e);
1754 }
1755 
1759 {
1760  Q_D(QTextEdit);
1762  d->sendControlEvent(e);
1763 }
1764 
1768 {
1769  Q_D(QTextEdit);
1770  if (!d->anchorToScrollToWhenVisible.isEmpty()) {
1771  scrollToAnchor(d->anchorToScrollToWhenVisible);
1772  d->anchorToScrollToWhenVisible.clear();
1773  d->showCursorOnInitialShow = false;
1774  } else if (d->showCursorOnInitialShow) {
1775  d->showCursorOnInitialShow = false;
1777  }
1778 }
1779 
1783 {
1784  Q_D(QTextEdit);
1787  || e->type() == QEvent::FontChange) {
1788  d->control->document()->setDefaultFont(font());
1789  } else if(e->type() == QEvent::ActivationChange) {
1790  if (!isActiveWindow())
1791  d->autoScrollTimer.stop();
1792  } else if (e->type() == QEvent::EnabledChange) {
1793  e->setAccepted(isEnabled());
1794  d->control->setPalette(palette());
1795  d->sendControlEvent(e);
1796  } else if (e->type() == QEvent::PaletteChange) {
1797  d->control->setPalette(palette());
1798  } else if (e->type() == QEvent::LayoutDirectionChange) {
1799  d->sendControlEvent(e);
1800  }
1801 }
1802 
1805 #ifndef QT_NO_WHEELEVENT
1807 {
1808  Q_D(QTextEdit);
1809  if (!(d->control->textInteractionFlags() & Qt::TextEditable)) {
1810  if (e->modifiers() & Qt::ControlModifier) {
1811  const int delta = e->delta();
1812  if (delta < 0)
1813  zoomOut();
1814  else if (delta > 0)
1815  zoomIn();
1816  return;
1817  }
1818  }
1820  updateMicroFocus();
1821 }
1822 #endif
1823 
1824 #ifndef QT_NO_CONTEXTMENU
1825 
1835 {
1836  Q_D(QTextEdit);
1837  return d->control->createStandardContextMenu(QPointF(), this);
1838 }
1839 
1854 {
1855  Q_D(QTextEdit);
1856  return d->control->createStandardContextMenu(position, this);
1857 }
1858 #endif // QT_NO_CONTEXTMENU
1859 
1864 {
1865  Q_D(const QTextEdit);
1866  return d->control->cursorForPosition(d->mapToContents(pos));
1867 }
1868 
1874 {
1875  Q_D(const QTextEdit);
1876  if (cursor.isNull())
1877  return QRect();
1878 
1879  QRect r = d->control->cursorRect(cursor).toRect();
1880  r.translate(-d->horizontalOffset(),-d->verticalOffset());
1881  return r;
1882 }
1883 
1889 {
1890  Q_D(const QTextEdit);
1891  QRect r = d->control->cursorRect().toRect();
1892  r.translate(-d->horizontalOffset(),-d->verticalOffset());
1893  return r;
1894 }
1895 
1896 
1902 {
1903  Q_D(const QTextEdit);
1904  return d->control->anchorAt(d->mapToContents(pos));
1905 }
1906 
1925 bool QTextEdit::overwriteMode() const
1926 {
1927  Q_D(const QTextEdit);
1928  return d->control->overwriteMode();
1929 }
1930 
1931 void QTextEdit::setOverwriteMode(bool overwrite)
1932 {
1933  Q_D(QTextEdit);
1934  d->control->setOverwriteMode(overwrite);
1935 }
1936 
1948 int QTextEdit::tabStopWidth() const
1949 {
1950  Q_D(const QTextEdit);
1951  return qRound(d->control->document()->defaultTextOption().tabStop());
1952 }
1953 
1955 {
1956  Q_D(QTextEdit);
1957  QTextOption opt = d->control->document()->defaultTextOption();
1958  if (opt.tabStop() == width || width < 0)
1959  return;
1960  opt.setTabStop(width);
1961  d->control->document()->setDefaultTextOption(opt);
1962 }
1963 
1973 int QTextEdit::cursorWidth() const
1974 {
1975  Q_D(const QTextEdit);
1976  return d->control->cursorWidth();
1977 }
1978 
1980 {
1981  Q_D(QTextEdit);
1982  d->control->setCursorWidth(width);
1983 }
1984 
1999 bool QTextEdit::acceptRichText() const
2000 {
2001  Q_D(const QTextEdit);
2002  return d->control->acceptRichText();
2003 }
2004 
2006 {
2007  Q_D(QTextEdit);
2008  d->control->setAcceptRichText(accept);
2009 }
2010 
2048 {
2049  Q_D(QTextEdit);
2050  d->control->setExtraSelections(selections);
2051 }
2052 
2063 {
2064  Q_D(const QTextEdit);
2065  return d->control->extraSelections();
2066 }
2067 
2079 {
2080  Q_D(const QTextEdit);
2081  return d->control->QTextControl::createMimeDataFromSelection();
2082 }
2083 
2094 {
2095  Q_D(const QTextEdit);
2096  return d->control->QTextControl::canInsertFromMimeData(source);
2097 }
2098 
2109 {
2110  Q_D(QTextEdit);
2111  d->control->QTextControl::insertFromMimeData(source);
2112 }
2113 
2128 {
2129  Q_D(const QTextEdit);
2130  return !(d->control->textInteractionFlags() & Qt::TextEditable);
2131 }
2132 
2134 {
2135  Q_D(QTextEdit);
2136  Qt::TextInteractionFlags flags = Qt::NoTextInteraction;
2137  if (ro) {
2138  flags = Qt::TextSelectableByMouse;
2139 #ifndef QT_NO_TEXTBROWSER
2140  if (qobject_cast<QTextBrowser *>(this))
2141  flags |= Qt::TextBrowserInteraction;
2142 #endif
2143  } else {
2144  flags = Qt::TextEditorInteraction;
2145  }
2146  d->control->setTextInteractionFlags(flags);
2148 }
2149 
2163 void QTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags)
2164 {
2165  Q_D(QTextEdit);
2166  d->control->setTextInteractionFlags(flags);
2167 }
2168 
2169 Qt::TextInteractionFlags QTextEdit::textInteractionFlags() const
2170 {
2171  Q_D(const QTextEdit);
2172  return d->control->textInteractionFlags();
2173 }
2174 
2184 {
2185  Q_D(QTextEdit);
2186  d->control->mergeCurrentCharFormat(modifier);
2187 }
2188 
2196 {
2197  Q_D(QTextEdit);
2198  d->control->setCurrentCharFormat(format);
2199 }
2200 
2205 {
2206  Q_D(const QTextEdit);
2207  return d->control->currentCharFormat();
2208 }
2209 
2225 QTextEdit::AutoFormatting QTextEdit::autoFormatting() const
2226 {
2227  Q_D(const QTextEdit);
2228  return d->autoFormatting;
2229 }
2230 
2231 void QTextEdit::setAutoFormatting(AutoFormatting features)
2232 {
2233  Q_D(QTextEdit);
2234  d->autoFormatting = features;
2235 }
2236 
2246 {
2247  Q_D(QTextEdit);
2248  d->control->insertPlainText(text);
2249 }
2250 
2264 #ifndef QT_NO_TEXTHTMLPARSER
2266 {
2267  Q_D(QTextEdit);
2268  d->control->insertHtml(text);
2269 }
2270 #endif // QT_NO_TEXTHTMLPARSER
2271 
2278 {
2279  Q_D(QTextEdit);
2280  if (name.isEmpty())
2281  return;
2282 
2283  if (!isVisible()) {
2284  d->anchorToScrollToWhenVisible = name;
2285  return;
2286  }
2287 
2288  QPointF p = d->control->anchorPosition(name);
2289  const int newPosition = qRound(p.y());
2290  if ( d->vbar->maximum() < newPosition )
2291  d->_q_adjustScrollbars();
2292  d->vbar->setValue(newPosition);
2293 }
2294 
2307 void QTextEdit::zoomIn(int range)
2308 {
2309  QFont f = font();
2310  const int newSize = f.pointSize() + range;
2311  if (newSize <= 0)
2312  return;
2313  f.setPointSize(newSize);
2314  setFont(f);
2315 }
2316 
2331 void QTextEdit::zoomOut(int range)
2332 {
2333  zoomIn(-range);
2334 }
2335 
2350 {
2351  Q_D(QTextEdit);
2352  d->control->moveCursor(operation, mode);
2353 }
2354 
2363 {
2364  Q_D(const QTextEdit);
2365  return d->control->canPaste();
2366 }
2367 
2368 #ifndef QT_NO_PRINTER
2369 
2380 void QTextEdit::print(QPrinter *printer) const
2381 {
2382  Q_D(const QTextEdit);
2383  d->control->print(printer);
2384 }
2385 #endif // QT _NO_PRINTER
2386 
2399 bool QTextEdit::tabChangesFocus() const
2400 {
2401  Q_D(const QTextEdit);
2402  return d->tabChangesFocus;
2403 }
2404 
2406 {
2407  Q_D(QTextEdit);
2408  d->tabChangesFocus = b;
2409 }
2410 
2440 {
2441  Q_D(const QTextEdit);
2442  return d->lineWrap;
2443 }
2444 
2446 {
2447  Q_D(QTextEdit);
2448  if (d->lineWrap == wrap)
2449  return;
2450  d->lineWrap = wrap;
2451  d->updateDefaultTextOption();
2452  d->relayoutDocument();
2453 }
2454 
2474 {
2475  Q_D(const QTextEdit);
2476  return d->lineWrapColumnOrWidth;
2477 }
2478 
2480 {
2481  Q_D(QTextEdit);
2482  d->lineWrapColumnOrWidth = w;
2483  d->relayoutDocument();
2484 }
2485 
2499 {
2500  Q_D(const QTextEdit);
2501  return d->wordWrap;
2502 }
2503 
2505 {
2506  Q_D(QTextEdit);
2507  if (mode == d->wordWrap)
2508  return;
2509  d->wordWrap = mode;
2510  d->updateDefaultTextOption();
2511 }
2512 
2518 bool QTextEdit::find(const QString &exp, QTextDocument::FindFlags options)
2519 {
2520  Q_D(QTextEdit);
2521  return d->control->find(exp, options);
2522 }
2523 
2592 {
2593  Q_D(QTextEdit);
2594  Qt::TextFormat format = d->textFormat;
2595  if (d->textFormat == Qt::AutoText)
2596  format = Qt::mightBeRichText(text) ? Qt::RichText : Qt::PlainText;
2597 #ifndef QT_NO_TEXTHTMLPARSER
2598  if (format == Qt::RichText || format == Qt::LogText)
2599  setHtml(text);
2600  else
2601 #endif
2602  setPlainText(text);
2603 }
2604 
2605 #ifdef QT3_SUPPORT
2606 
2609 void QTextEdit::moveCursor(CursorAction action, QTextCursor::MoveMode mode)
2610 {
2611  Q_D(QTextEdit);
2612  if (action == MovePageUp) {
2613  d->pageUpDown(QTextCursor::Up, mode);
2614  return;
2615  } else if (action == MovePageDown) {
2616  d->pageUpDown(QTextCursor::Down, mode);
2617  return;
2618  }
2619 
2620  QTextCursor cursor = d->control->textCursor();
2622  switch (action) {
2623  case MoveBackward: op = QTextCursor::Left; break;
2624  case MoveForward: op = QTextCursor::Right; break;
2625  case MoveWordBackward: op = QTextCursor::WordLeft; break;
2626  case MoveWordForward: op = QTextCursor::WordRight; break;
2627  case MoveUp: op = QTextCursor::Up; break;
2628  case MoveDown: op = QTextCursor::Down; break;
2629  case MoveLineStart: op = QTextCursor::StartOfLine; break;
2630  case MoveLineEnd: op = QTextCursor::EndOfLine; break;
2631  case MoveHome: op = QTextCursor::Start; break;
2632  case MoveEnd: op = QTextCursor::End; break;
2633  default: return;
2634  }
2635  cursor.movePosition(op, mode);
2636  d->control->setTextCursor(cursor);
2637 }
2638 
2642 void QTextEdit::moveCursor(CursorAction action, bool select)
2643 {
2645 }
2646 
2654 void QTextEdit::doKeyboardAction(KeyboardAction action)
2655 {
2656  Q_D(QTextEdit);
2657  QTextCursor cursor = d->control->textCursor();
2658  switch (action) {
2659  case ActionBackspace: cursor.deletePreviousChar(); break;
2660  case ActionDelete: cursor.deleteChar(); break;
2661  case ActionReturn: cursor.insertBlock(); break;
2662  case ActionKill: {
2663  QTextBlock block = cursor.block();
2664  if (cursor.position() == block.position() + block.length() - 2)
2666  else
2668  cursor.deleteChar();
2669  break;
2670  }
2671  case ActionWordBackspace:
2673  cursor.deletePreviousChar();
2674  break;
2675  case ActionWordDelete:
2677  cursor.deleteChar();
2678  break;
2679  }
2680  d->control->setTextCursor(cursor);
2681 }
2682 
2686 QString QTextEdit::text() const
2687 {
2688  Q_D(const QTextEdit);
2689  if (d->textFormat == Qt::RichText || d->textFormat == Qt::LogText || (d->textFormat == Qt::AutoText && d->preferRichText))
2690  return d->control->toHtml();
2691  else
2692  return d->control->toPlainText();
2693 }
2694 
2695 
2701 void QTextEdit::setTextFormat(Qt::TextFormat f)
2702 {
2703  Q_D(QTextEdit);
2704  d->textFormat = f;
2705 }
2706 
2712 Qt::TextFormat QTextEdit::textFormat() const
2713 {
2714  Q_D(const QTextEdit);
2715  return d->textFormat;
2716 }
2717 
2718 #endif // QT3_SUPPORT
2719 
2730 {
2731  Q_D(QTextEdit);
2732  const bool atBottom = isReadOnly() ? d->verticalOffset() >= d->vbar->maximum() :
2733  d->control->textCursor().atEnd();
2734  d->control->append(text);
2735  if (atBottom)
2736  d->vbar->setValue(d->vbar->maximum());
2737 }
2738 
2744 {
2745  Q_D(QTextEdit);
2746  d->control->ensureCursorVisible();
2747 }
2748 
2999 #endif // QT_NO_TEXTEDIT
3000 
3002 
3003 #include "moc_qtextedit.cpp"
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPoint pos() const
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QSizeF pageSize
the page size that should be used for laying out the document
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
virtual bool event(QEvent *e)
Definition: qtextedit.cpp:1071
virtual void changeEvent(QEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1782
QTextCursor cursorForPosition(const QPoint &pos) const
returns a QTextCursor at position pos (in viewport coordinates).
Definition: qtextedit.cpp:1863
QFont font() const
Returns the font for this character format.
void zoomIn(int range=1)
Zooms in on the text by making the base font size range points larger and recalculating all font size...
Definition: qtextedit.cpp:2307
virtual void dragLeaveEvent(QDragLeaveEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1670
AutoFormatting autoFormatting() const
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
QTextEditControl(QObject *parent)
Definition: qtextedit.cpp:85
void append(const QString &text)
Appends a new paragraph with text to the end of the text edit.
Definition: qtextedit.cpp:2729
void print(QPrinter *printer) const
Convenience function to print the text edit&#39;s document to the given printer.
Definition: qtextedit.cpp:2380
void endEditBlock()
Indicates the end of a block of editing operations on the document that should appear as a single ope...
virtual void showEvent(QShowEvent *)
Reimplemented Function
Definition: qtextedit.cpp:1767
void setTabChangesFocus(bool b)
Definition: qtextedit.cpp:2405
The QKeyEvent class describes a key event.
Definition: qevent.h:224
void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode)
Definition: qtextedit.cpp:211
bool isNull() const
Returns true if both the width and height are +0.
Definition: qsize.h:275
int type
Definition: qmetatype.cpp:239
virtual void dropEvent(QDropEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1691
void setTabStopWidth(int width)
Definition: qtextedit.cpp:1954
void setFontItalic(bool italic)
If italic is true, sets the text format&#39;s font to be italic; otherwise the font will be non-italic...
Definition: qtextformat.h:415
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
double qreal
Definition: qglobal.h:1193
The QTextListFormat class provides formatting information for lists in a QTextDocument.
Definition: qtextformat.h:642
void setLineWrapColumnOrWidth(int w)
Definition: qtextedit.cpp:2479
unsigned char c[8]
Definition: qnumeric_p.h:62
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
void setFontPointSize(qreal s)
Sets the point size of the current format to s.
Definition: qtextedit.cpp:850
QPointF toPointF() const
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null...
Definition: qvariant.cpp:2509
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QCursor cursor() const
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:661
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
void setAutoFormatting(AutoFormatting features)
Definition: qtextedit.cpp:2231
QRect cursorRect() const
returns a rectangle (in viewport coordinates) that includes the cursor of the text edit...
Definition: qtextedit.cpp:1888
void setTextCursor(const QTextCursor &cursor)
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
Qt::Alignment alignment() const
Returns the alignment of the current paragraph.
Definition: qtextedit.cpp:774
void setWordWrapMode(QTextOption::WrapMode policy)
Definition: qtextedit.cpp:2504
void setFontWeight(int w)
Sets the font weight of the current format to the given weight, where the value used is in the range ...
Definition: qtextedit.cpp:869
QSize toSize() const
Returns an integer based copy of this size.
Definition: qsize.h:355
bool isEmpty() const
Returns true if the document is empty; otherwise returns false.
void setTextBackgroundColor(const QColor &c)
Sets the text background color of the current format to c.
Definition: qtextedit.cpp:924
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
QLayout * layout
Definition: qwidget_p.h:704
bool isVisible() const
Definition: qwidget.h:1005
void setFontUnderline(bool b)
If underline is true, sets the current format to underline; otherwise sets the current format to non-...
Definition: qtextedit.cpp:882
int horizontalOffset() const
Definition: qtextedit_p.h:93
void setPalette(const QPalette &pal)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
virtual bool canInsertFromMimeData(const QMimeData *source) const
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
virtual void wheelEvent(QWheelEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1806
bool find(const QString &exp, QTextDocument::FindFlags options=0)
Finds the next occurrence of the string, exp, using the given options.
Definition: qtextedit.cpp:2518
#define SLOT(a)
Definition: qobjectdefs.h:226
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void paste()
Pastes the text from the clipboard into the text edit at the current cursor position.
Definition: qtextedit.cpp:1036
void ensureCursorVisible()
Ensures that the cursor is visible by scrolling the text edit if necessary.
Definition: qtextedit.cpp:2743
void setIndent(int indent)
Sets the list format&#39;s indentation.
Definition: qtextformat.h:685
QTextCharFormat currentCharFormat() const
Returns the char format that is used when inserting new text.
Definition: qtextedit.cpp:2204
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
WrapMode
This enum describes how text is wrapped in a document.
Definition: qtextoption.h:102
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
void setFont(const QFont &font)
Sets the text format&#39;s font.
int lineWrapColumnOrWidth() const
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
Definition: qtextedit.cpp:2163
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
void setTextColor(const QColor &c)
Sets the text color of the current format to c.
Definition: qtextedit.cpp:907
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void triggerAction(SliderAction action)
Triggers a slider action.
virtual bool focusNextPrevChild(bool next)
Reimplemented Function
Definition: qtextedit.cpp:1627
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
void setPageSize(const QSizeF &size)
qreal fontPointSize() const
Returns the point size of the font of the current format.
Definition: qtextedit.cpp:663
static QSize documentSize(QTextControl *control)
Definition: qtextedit.cpp:238
long ASN1_INTEGER_get ASN1_INTEGER * a
bool atBlockStart() const
Returns true if the cursor is at the start of a block; otherwise returns false.
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
QString anchorHref() const
Returns the text format&#39;s hypertext link, or an empty string if none has been set.
Definition: qtextformat.h:506
virtual bool canInsertFromMimeData(const QMimeData *source) const
Definition: qtextedit.cpp:93
virtual void mousePressEvent(QMouseEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1575
void setBackground(const QBrush &brush)
Sets the brush use to paint the document&#39;s background to the brush specified.
Definition: qtextformat.h:343
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
bool isActiveWindow() const
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
QRectF intersected(const QRectF &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:818
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QRectF toRectF() const
Returns the variant as a QRectF if the variant has type() Rect or RectF ; otherwise returns an invali...
Definition: qvariant.cpp:2463
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
Definition: qevent.h:530
bool acceptRichText() const
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
int indent() const
Returns the paragraph&#39;s indent.
Definition: qtextformat.h:590
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void relayoutDocument()
Definition: qtextedit.cpp:1434
void mergeBlockFormat(const QTextBlockFormat &modifier)
Modifies the block format of the current block (or all blocks that are contained in the selection) wi...
#define Q_D(Class)
Definition: qglobal.h:2482
void setCursorWidth(int width)
Definition: qtextedit.cpp:1979
int tabStopWidth() const
virtual void dragEnterEvent(QDragEnterEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1661
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
static bool shouldEnableInputMethod(QTextEdit *textedit)
Definition: qtextedit.cpp:77
void setCurrentCharFormat(const QTextCharFormat &format)
Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCha...
Definition: qtextedit.cpp:2195
virtual void insertFromMimeData(const QMimeData *source)
void setLineWrapMode(LineWrapMode mode)
Definition: qtextedit.cpp:2445
qreal tabStop() const
Returns the distance in device units between tab stops.
Definition: qtextoption.h:124
QTextCursor textCursor() const
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition: qwidget.cpp:9457
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setRange(int min, int max)
Sets the slider&#39;s minimum to min and its maximum to max.
void setDefaultTextOption(const QTextOption &option)
Sets the default text option.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
virtual void timerEvent(QTimerEvent *e)
Definition: qtextedit.cpp:1102
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
Definition: qtextedit.cpp:813
void setFontWeight(int weight)
Sets the text format&#39;s font weight to weight.
Definition: qtextformat.h:411
int position() const
Returns the index of the block&#39;s first character within the document.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void wheelEvent(QWheelEvent *)
This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widg...
QWidget * viewport() const
Returns the viewport widget.
void setDocument(QTextDocument *document)
Makes document the new document of the text editor.
Definition: qtextedit.cpp:791
bool canPaste() const
Returns whether text can be pasted from the clipboard into the textedit.
Definition: qtextedit.cpp:2362
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void _q_currentCharFormatChanged(const QTextCharFormat &format)
Definition: qtextedit.cpp:1546
void _q_repaintContents(const QRectF &contentsRect)
Definition: qtextedit.cpp:193
uint ignoreAutomaticScrollbarAdjustment
Definition: qtextedit_p.h:121
int width() const
Returns the width.
Definition: qsize.h:126
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
virtual void scrollContentsBy(int dx, int dy)
em>Reimplemented Function
Definition: qtextedit.cpp:1718
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
MoveMode
If the anchor() is kept where it is and the position() is moved, the text in between will be selected...
Definition: qtextcursor.h:85
QSizeF dynamicDocumentSize() const
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isAccepted() const
Definition: qcoreevent.h:307
virtual void mouseMoveEvent(QMouseEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1587
bool visible
whether the widget is visible
Definition: qwidget.h:191
virtual void keyReleaseEvent(QKeyEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1365
void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qframe.cpp:574
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
QList< ExtraSelection > extraSelections() const
Returns previously set extra selections.
Definition: qtextedit.cpp:2062
void setExtraSelections(const QList< ExtraSelection > &selections)
This function allows temporarily marking certain regions in the document with a given color...
Definition: qtextedit.cpp:2047
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
virtual void mouseReleaseEvent(QMouseEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1604
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setBlockFormat(const QTextBlockFormat &format)
Sets the block format of the current block (or all blocks that are contained in the selection) to for...
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
int width() const
virtual QSizeF documentSize() const =0
Returns the total size of the document&#39;s layout.
const char * name
The QPrinter class is a paint device that paints on a printer.
Definition: qprinter.h:66
void clear()
Deletes all the text in the text edit.
Definition: qtextedit.cpp:1050
#define emit
Definition: qobjectdefs.h:76
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void setHtml(const QString &text)
const QPalette & palette() const
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
virtual void dragMoveEvent(QDragMoveEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1680
bool fontUnderline() const
Returns true if the font of the current format is underlined; otherwise returns false.
Definition: qtextedit.cpp:697
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
virtual void inputMethodEvent(QInputMethodEvent *)
Reimplemented Function
Definition: qtextedit.cpp:1703
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
void updateDefaultTextOption()
Definition: qtextedit.cpp:1557
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
virtual QMimeData * createMimeDataFromSelection() const
void setFontPointSize(qreal size)
Sets the text format&#39;s font size.
Definition: qtextformat.h:406
bool fontItalic() const
Returns true if the font of the current format is italic; otherwise returns false.
Definition: qtextedit.cpp:709
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
QTextEdit(QWidget *parent=0)
Constructs an empty QTextEdit with parent parent.
Definition: qtextedit.cpp:608
const QSize & oldSize() const
Returns the old size of the widget.
Definition: qevent.h:356
void _q_ensureVisible(const QRectF &rect)
Definition: qtextedit.cpp:308
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1619
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
void updateMicroFocus()
Updates the widget&#39;s micro focus.
Definition: qwidget.cpp:11820
QString fontFamily() const
Returns the font family of the current format.
Definition: qtextedit.cpp:674
int position() const
Returns the absolute position of the cursor within the document.
int length() const
Returns the length of the block in characters.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
virtual void focusOutEvent(QFocusEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1758
int fontWeight() const
Returns the font weight of the current format.
Definition: qtextedit.cpp:685
virtual QMimeData * createMimeDataFromSelection() const
This function returns a new MIME data object to represent the contents of the text edit&#39;s current sel...
Definition: qtextedit.cpp:2078
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.
bool tabChangesFocus() const
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
QRect rect() const
QTextList * currentList() const
Returns the current list if the cursor position() is inside a block that is part of a list; otherwise...
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
QTextBlock block() const
Returns the block that contains the cursor.
bool isEnabled() const
Definition: qwidget.h:948
QTextDocument * document() const
Qt::TextInteractionFlags textInteractionFlags() const
void undo()
Undoes the last operation.
Definition: qtextedit.cpp:956
TextFormat
Definition: qnamespace.h:1310
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
QFont currentFont() const
Returns the font of the current format.
Definition: qtextedit.cpp:747
InputMethodQuery
Definition: qnamespace.h:1541
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...
void setFontItalic(bool b)
If italic is true, sets the current format to italic; otherwise sets the current format to non-italic...
Definition: qtextedit.cpp:895
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
void setPlainText(const QString &text)
Changes the text of the text edit to the string text.
Definition: qtextedit.cpp:1156
void paint(QPainter *p, QPaintEvent *e)
Definition: qtextedit.cpp:1508
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
Definition: qtextedit.cpp:824
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
void setAlignment(Qt::Alignment alignment)
Sets the paragraph&#39;s alignment.
Definition: qtextformat.h:619
virtual void resizeEvent(QResizeEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1410
void remove(const QTextBlock &)
Removes the given block from the list.
Definition: qtextlist.cpp:319
void beginEditBlock()
Indicates the start of a block of editing operations on the document that should appear as a single o...
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
QColor textColor() const
Returns the text color of the current format.
Definition: qtextedit.cpp:720
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
virtual QVariant loadResource(int type, const QUrl &name)
Loads the resource specified by the given type and name.
Definition: qtextedit.cpp:1401
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
QVariant inputMethodQuery(Qt::InputMethodQuery property) const
This method is only relevant for input widgets.
Definition: qtextedit.cpp:1728
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QMenu * createStandardContextMenu()
This function creates the standard context menu which is shown when the user clicks on the text edit ...
Definition: qtextedit.cpp:1834
QString text() const
Returns the Unicode text that this key generated.
Definition: qevent.h:236
void scrollToAnchor(const QString &name)
Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is ...
Definition: qtextedit.cpp:2277
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
const QSize & size() const
Returns the new size of the widget.
Definition: qevent.h:355
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
virtual void contextMenuEvent(QContextMenuEvent *e)
Shows the standard context menu created with createStandardContextMenu().
Definition: qtextedit.cpp:1651
void setFontUnderline(bool underline)
If underline is true, sets the text format&#39;s font to be underlined; otherwise it is displayed non-und...
Definition: qtextformat.h:432
void copy()
Copies any selected text to the clipboard.
Definition: qtextedit.cpp:1016
LineWrapMode lineWrapMode() const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void insertHtml(const QString &text)
Convenience slot that inserts text which is assumed to be of html formatting at the current cursor po...
Definition: qtextedit.cpp:2265
void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
Moves the cursor by performing the given operation.
Definition: qtextedit.cpp:2349
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804
bool overwriteMode() const
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
virtual QMimeData * createMimeDataFromSelection() const
Definition: qtextedit.cpp:87
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836
void deletePreviousChar()
If there is no selected text, deletes the character before the current cursor position; otherwise del...
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
bool isNull() const
Returns true if the cursor is null; otherwise returns false.
virtual void insertFromMimeData(const QMimeData *source)
This function inserts the contents of the MIME data object, specified by source, into the text edit a...
Definition: qtextedit.cpp:2108
QTextControl * control
Definition: qtextedit_p.h:109
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
Definition: qtextformat.h:352
void setFontFamily(const QString &family)
Sets the text format&#39;s font family.
Definition: qtextformat.h:401
void setUndoRedoEnabled(bool enable)
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
Definition: qtextoption.h:110
void setOverwriteMode(bool overwrite)
Definition: qtextedit.cpp:1931
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
Definition: qevent.h:237
void setIndent(int indent)
Sets the paragraph&#39;s indentation.
Definition: qtextformat.h:622
void _q_adjustScrollbars()
Definition: qtextedit.cpp:258
Qt::FocusReason reason()
Definition: qevent.cpp:1197
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
int verticalOffset() const
Definition: qtextedit_p.h:95
virtual ~QTextEdit()
Destructor.
Definition: qtextedit.cpp:654
void setCurrentFont(const QFont &f)
Sets the font of the current format to f.
Definition: qtextedit.cpp:936
void cut()
Copies the selected text to the clipboard and deletes it from the text edit.
Definition: qtextedit.cpp:1004
void insertPlainText(const QString &text)
Convenience slot that inserts text at the current cursor position.
Definition: qtextedit.cpp:2245
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QObject * parent
Definition: qobject.h:92
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
virtual void insertFromMimeData(const QMimeData *source)
Definition: qtextedit.cpp:99
bool event(QEvent *)
Reimplemented Function
uint showCursorOnInitialShow
Definition: qtextedit_p.h:123
QString anchorAt(const QPoint &pos) const
Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that p...
Definition: qtextedit.cpp:1901
void setPaintDevice(QPaintDevice *device)
Sets the paint device used for rendering the document&#39;s layout to the given device.
virtual void paintEvent(QPaintEvent *e)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qtextedit.cpp:1539
void setFontFamily(const QString &fontFamily)
Sets the font family of the current format to fontFamily.
Definition: qtextedit.cpp:835
The QTextList class provides a decorated list of items in a QTextDocument.
Definition: qtextlist.h:57
void setWrapMode(WrapMode wrap)
Sets the option&#39;s text wrap mode to the given mode.
Definition: qtextoption.h:109
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
Definition: qtextformat.h:350
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
const QFont & font() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void keyPressEvent(QKeyEvent *)
This function is called with key event e when key presses occur.
bool isRightToLeft() const
Definition: qwidget.h:428
void selectAll()
Selects all text.
Definition: qtextedit.cpp:1063
void setSingleFingerPanEnabled(bool on=true)
QTextOption::WrapMode wordWrapMode() const
the mode QTextEdit will use when wrapping text by words
Definition: qtextedit.cpp:2498
void zoomOut(int range=1)
Zooms out on the text by making the base font size range points smaller and recalculating all font si...
Definition: qtextedit.cpp:2331
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void setAcceptRichText(bool accept)
Definition: qtextedit.cpp:2005
virtual void focusInEvent(QFocusEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1746
void setViewport(const QRectF &viewport)
const QRect & rect() const
Returns the rectangle that needs to be updated.
Definition: qevent.h:305
void deleteChar()
If there is no selected text, deletes the character at the current cursor position; otherwise deletes...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
int maximum() const
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
void setAlignment(Qt::Alignment a)
Sets the alignment of the current paragraph to a.
Definition: qtextedit.cpp:759
void setStyle(Style style)
Sets the list format&#39;s style.
Definition: qtextformat.h:682
QTextOption defaultTextOption() const
the default text option will be set on all QTextLayout in the document.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void redo()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qtextedit.cpp:962
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void setReadOnly(bool ro)
Definition: qtextedit.cpp:2133
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431
void setText(const QString &text)
Sets the text edit&#39;s text.
Definition: qtextedit.cpp:2591
bool isReadOnly() const
Definition: qtextedit.cpp:2127
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
int cursorWidth() const
void createAutoBulletList()
Definition: qtextedit.cpp:121
void setHtml(const QString &text)
Definition: qtextedit.cpp:1200
virtual void keyPressEvent(QKeyEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1210
QRectF cursorRect(const QTextCursor &cursor) const
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
Definition: qvariant.cpp:2400
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
void setTabStop(qreal tabStop)
Sets the default distance in device units between tab stops to the value specified by tabStop...
Definition: qtextoption.h:154
QColor textBackgroundColor() const
Returns the text background color of the current format.
Definition: qtextedit.cpp:736
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486
#define text
Definition: qobjectdefs.h:80
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
virtual bool canInsertFromMimeData(const QMimeData *source) const
This function returns true if the contents of the MIME data object, specified by source, can be decoded and inserted into the document.
Definition: qtextedit.cpp:2093
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for ...
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311