aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h
diff options
context:
space:
mode:
authorMohammadHossein Qanbari <mohammad.qanbari@qt.io>2024-08-23 17:12:51 +0200
committerMohammadHossein Qanbari <mohammad.qanbari@qt.io>2024-09-02 22:46:58 +0200
commit8330154be6401569450b97512b6718b0f31d6eaf (patch)
treefc7736297b321a2592dcaf59f7e7e1edc7cbe8fe /examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h
parent2f9e1e55766af3123189ccddbfa63139ecf53fec (diff)
QML Previewer Example: Add Error List and Line Numbers
Implement LineNumberArea to display line numbers, based on the Code Editor Example documentation. Introduce QListView with ErrorListModel to show errors and warnings. Double-clicking an error in the list moves the code editor's cursor to the corresponding position. Update shortcut functionality to work only on platforms where the feature is available. Related code has been modified accordingly. Fixes: QTBUG-128227 Pick-to: 6.8 Change-Id: Icb66280a5360b015280afc756f8a827247a2ebaf Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h')
-rw-r--r--examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h b/examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h
new file mode 100644
index 0000000000..16b739a900
--- /dev/null
+++ b/examples/quick/quickwidgets/qmlpreviewer/widgets/previewwidget.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PREVIEWWIDGET_H
+#define PREVIEWWIDGET_H
+
+#include "../models/errorlistmodel.h"
+#include <QWidget>
+
+class QListView;
+class QQuickWidget;
+
+class PreviewWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit PreviewWidget(QWidget *parent = nullptr);
+
+ QString sourcePath() const;
+ void setSourcePath(const QString &path);
+
+private:
+ void initUI();
+ void setupConnections();
+
+signals:
+ void errorPositionSelected(int line, int column);
+
+private slots:
+ void onAppStateChanged(int oldState, int newState);
+ void onQuickWidetStatusChanged(int status);
+
+private:
+ ErrorListModel m_errorListModel;
+ QListView *m_errorListView = nullptr;
+ QQuickWidget *m_quickWidget = nullptr;
+};
+
+#endif // PREVIEWWIDGET_H