summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tools/settingseditor/settingstree.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-08-27 17:23:55 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-09-23 13:28:02 +0000
commit47e4ae86a8d87ec6388d9423aba86d1498b49012 (patch)
tree697a90c9e0d3e2213b054dd3a2ad21f9883d99e2 /examples/widgets/tools/settingseditor/settingstree.h
parent2e02130e394083f8bc7fa04a8e0b6e0c0ed4e1b2 (diff)
Polish the settings editor example.
- Set QtProject as organization. - Remove unneeded member variables. - Use member initialization in the constructor. - Use new connection syntax in createActions() to assemble the menu there, removing the createMenus() function. - Introduce a QSharedPointer to ensure settings are deleted. Previously, the settings were parented on the tree widget, which is a hack of sorts. - Fix OS X macros. Change-Id: Ibbc6bfb03eb5c7eda077b1a3aa3f1707667f7f13 Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'examples/widgets/tools/settingseditor/settingstree.h')
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/widgets/tools/settingseditor/settingstree.h b/examples/widgets/tools/settingseditor/settingstree.h
index 2a64a5a496..4f542d2543 100644
--- a/examples/widgets/tools/settingseditor/settingstree.h
+++ b/examples/widgets/tools/settingseditor/settingstree.h
@@ -44,6 +44,7 @@
#include <QIcon>
#include <QTimer>
#include <QTreeWidget>
+#include <QSharedPointer>
QT_BEGIN_NAMESPACE
class QSettings;
@@ -54,9 +55,12 @@ class SettingsTree : public QTreeWidget
Q_OBJECT
public:
+ typedef QSharedPointer<QSettings> SettingsPtr;
+
SettingsTree(QWidget *parent = 0);
+ ~SettingsTree();
- void setSettingsObject(QSettings *settings);
+ void setSettingsObject(const SettingsPtr &settings);
QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
@@ -80,7 +84,7 @@ private:
int findChild(QTreeWidgetItem *parent, const QString &text, int startIndex);
void moveItemForward(QTreeWidgetItem *parent, int oldIndex, int newIndex);
- QSettings *settings;
+ SettingsPtr settings;
QTimer refreshTimer;
bool autoRefresh;
QIcon groupIcon;