From 054fb061d770205706e80e80b6937edf7c866da1 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 8 Mar 2023 16:38:58 +0100 Subject: Fix warnings from deprecating QFileOpenEvent::openFile, update snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends 76c63936d3d3c937960108da88a56394a0ac70b5 by adjusting the test case. We still just test that we can open a file based on a filename that we came up with ourselves. Also, update usage documentation and make the snippet a bit more relevant. Change-Id: I5bf00210d74e2a73d5a71a09a5beb1b3f6f8e225 Reviewed-by: Axel Spoerl Reviewed-by: Tor Arne Vestbø --- src/gui/doc/snippets/qfileopenevent/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/gui/doc/snippets/qfileopenevent/main.cpp') diff --git a/src/gui/doc/snippets/qfileopenevent/main.cpp b/src/gui/doc/snippets/qfileopenevent/main.cpp index b733bfc320e..a94ff581373 100644 --- a/src/gui/doc/snippets/qfileopenevent/main.cpp +++ b/src/gui/doc/snippets/qfileopenevent/main.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Samuel Gaist +// Copyright (C) 2023 Samuel Gaist // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause //! [QApplication subclass] @@ -19,7 +19,15 @@ public: { if (event->type() == QEvent::FileOpen) { QFileOpenEvent *openEvent = static_cast(event); - qDebug() << "Open file" << openEvent->file(); + const QUrl url = openEvent->url(); + if (url.isLocalFile()) { + QFile localFile(url.toLocalFile()); + // read from local file + } else if (url.isValid()) { + // process according to the URL's schema + } else { + // parse openEvent->file() + } } return QApplication::event(event); -- cgit v1.2.3