summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/code')
-rw-r--r--doc/src/snippets/code/src_gui_painting_qpen.cpp4
-rw-r--r--doc/src/snippets/code/src_gui_qproxystyle.cpp45
-rw-r--r--doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp24
3 files changed, 71 insertions, 2 deletions
diff --git a/doc/src/snippets/code/src_gui_painting_qpen.cpp b/doc/src/snippets/code/src_gui_painting_qpen.cpp
index 538fa09..b5995f7 100644
--- a/doc/src/snippets/code/src_gui_painting_qpen.cpp
+++ b/doc/src/snippets/code/src_gui_painting_qpen.cpp
@@ -25,7 +25,7 @@ QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space
- << 27 << space << 9;
+ << 27 << space << 9 << space;
pen.setDashPattern(dashes);
//! [2]
@@ -36,6 +36,6 @@ QPen pen;
QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space
- << 27 << space << 9;
+ << 27 << space << 9 << space;
pen.setDashPattern(dashes);
//! [3]
diff --git a/doc/src/snippets/code/src_gui_qproxystyle.cpp b/doc/src/snippets/code/src_gui_qproxystyle.cpp
new file mode 100644
index 0000000..46a2a5f
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_qproxystyle.cpp
@@ -0,0 +1,45 @@
+//! [0]
+class MyProxyStyle : public QProxyStyle
+{
+public:
+
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 1;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+//! [0]
+
+//! [1]
+#include "textedit.h"
+#include <QApplication>
+#include <QProxyStyle>
+
+class MyProxyStyle : public QProxyStyle
+{
+ public:
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 0;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+int main(int argc, char **argv)
+{
+ Q_INIT_RESOURCE(textedit);
+
+ QApplication a(argc, argv);
+ a.setStyle(new MyProxyStyle);
+ TextEdit mw;
+ mw.resize(700, 800);
+ mw.show();
+ //...
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp b/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp
new file mode 100644
index 0000000..acd3938
--- /dev/null
+++ b/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp
@@ -0,0 +1,24 @@
+//! [0]
+QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
+diskCache->setCacheDirectory("cacheDir");
+manager->setCache(diskCache);
+//! [0]
+
+//! [1]
+// do a normal request (preferred from network, as this is the default)
+QNetworkRequest request(QUrl(QString("http://www.qtsoftware.com")));
+manager->get(request);
+
+// do a request preferred from cache
+QNetworkRequest request2(QUrl(QString("http://www.qtsoftware.com")));
+request2.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+manager->get(request2);
+//! [1]
+
+//! [2]
+void replyFinished(QNetworkReply *reply) {
+ QVariant fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
+ qDebug() << "page from cache?" << fromCache.toBool();
+}
+//! [2]