Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using QGuiApplication and not linking to QtWidgets #211

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2fc0f5c
Add wrappers around `QJsonValue`, `QJsonArray` and `QJsonObject`
Nov 12, 2021
a9becb5
Make it compile with older rustc than 1.56
Nov 12, 2021
50d97b4
Add more complete wrappers around QJson* types and add tests
Nov 14, 2021
1b74577
Merge branch 'woboq:master' into master
AdrianEddy Nov 15, 2021
3f52a88
Add a feature to skip linking with QtWidgets and use `QGuiApplication…
Nov 15, 2021
5dfc6c9
Fix build with QtWebEngine and add docs
Nov 15, 2021
1af5a5f
Fix build
Nov 15, 2021
4494571
Fix typo
Nov 15, 2021
8021f2a
Update to additive feature
Nov 15, 2021
dba9a3a
Add a define to build.rs and use #ifdef
Nov 15, 2021
2d239bd
Minor updates
Nov 16, 2021
d572c48
Merge branch 'woboq:master' into master
AdrianEddy Nov 16, 2021
fb883b4
Merge branch 'woboq:master' into master
AdrianEddy Nov 19, 2021
22b2ebb
Merge branch 'woboq:master' into master
AdrianEddy Nov 19, 2021
6b5e476
Merge branch 'woboq:master' into master
AdrianEddy Dec 15, 2021
e846147
Merge branch 'woboq:master' into master
AdrianEddy Jan 30, 2022
e359084
Fix building on Android. For some reason `-std=c++17` is not detected…
AdrianEddy Jan 30, 2022
a287bb1
Revert "Fix building on Android. For some reason `-std=c++17` is not …
AdrianEddy Jan 30, 2022
aa91b6d
Merge branch 'master' into master
AdrianEddy Feb 23, 2022
9e60580
Merge branch 'woboq:master' into master
AdrianEddy Feb 25, 2022
769069c
Merge branch 'woboq:master' into master
AdrianEddy Mar 24, 2022
6411d54
Merge branch 'woboq:master' into master
AdrianEddy Aug 20, 2022
102ae77
Merge branch 'woboq:master' into master
AdrianEddy Apr 3, 2023
12dcb16
Fix call to `QMetaObject::invokeMethod` in Qt 6.5
AdrianEddy May 5, 2023
0a2fdfa
Revert "Fix call to `QMetaObject::invokeMethod` in Qt 6.5"
AdrianEddy May 5, 2023
ecf70fb
Merge branch 'woboq:master' into master
AdrianEddy May 5, 2023
98ebed1
Merge remote-tracking branch 'upstream/master'
AdrianEddy Jul 12, 2023
59029b9
Merge branch 'woboq:master' into master
AdrianEddy Nov 6, 2023
ee6f5dc
Merge branch 'woboq:master' into master
AdrianEddy Sep 4, 2024
ff1e23d
Merge branch 'woboq:master' into master
AdrianEddy Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ Enables `QtWebEngine` functionality. For more details see the [example](./exampl

This feature is disabled by default.

### `widgets`

Link against **`qtwidgets`** module. This will use `QApplication` instead of `QGuiApplication`.

This feature is enabled by default.

## What if a wrapper for the Qt C++ API is missing?

It is quite likely that you would like to call a particular Qt function which
Expand Down
3 changes: 2 additions & 1 deletion qmetaobject/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ keywords = ["Qt", "QML", "QMetaObject",]
repository = "https://github.com/woboq/qmetaobject-rs"

[features]
default = ["log"]
default = ["log", "widgets"]
chrono_qdatetime = ["qttypes/chrono"]
webengine = ["qttypes/qtwebengine"]
widgets = ["qttypes/qtwidgets"]

[dependencies]
qttypes = { path = "../qttypes", version = "0.2.4", features = ["qtquick"] }
Expand Down
3 changes: 3 additions & 0 deletions qmetaobject/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ fn main() {
config.flag("-F");
config.flag(&qt_library_path);
}
if cfg!(not(feature = "widgets")) {
config.flag("-DNO_WIDGETS");
AdrianEddy marked this conversation as resolved.
Show resolved Hide resolved
}
if qt_version >= Version::new(6, 0, 0) {
config.flag_if_supported("-std=c++17");
config.flag_if_supported("/std:c++17");
Expand Down
13 changes: 10 additions & 3 deletions qmetaobject/src/qtdeclarative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ cpp! {{
#include <memory>
#include <QtQuick/QtQuick>
#include <QtCore/QDebug>
#include <QtWidgets/QApplication>
#include <QtQml/QQmlComponent>

#ifdef NO_WIDGETS
# define QAPPLICATION QGuiApplication
# include <QtGui/QGuiApplication>
#else
# define QAPPLICATION QApplication
# include <QtWidgets/QApplication>
#endif

struct SingleApplicationGuard {
SingleApplicationGuard() {
Expand All @@ -47,12 +54,12 @@ cpp! {{
};

struct QmlEngineHolder : SingleApplicationGuard {
std::unique_ptr<QApplication> app;
std::unique_ptr<QAPPLICATION> app;
std::unique_ptr<QQmlApplicationEngine> engine;
std::unique_ptr<QQuickView> view;

QmlEngineHolder(int &argc, char **argv)
: app(new QApplication(argc, argv))
: app(new QAPPLICATION(argc, argv))
, engine(new QQmlApplicationEngine())
{}
};
Expand Down
4 changes: 3 additions & 1 deletion qttypes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ qtmultimediawidgets = []
qtsql = []
# Link against QtTest
qttest = []
# Link against QtWidgets
qtwidgets = []

default = ["required"]
default = ["required", "qtwidgets"]

[dependencies]
cpp = "0.5.6"
Expand Down
3 changes: 2 additions & 1 deletion qttypes/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ fn main() {
};
link_lib("Core");
link_lib("Gui");
#[cfg(feature = "qtwidgets")]
link_lib("Widgets");
#[cfg(feature = "qtquick")]
link_lib("Quick");
Expand All @@ -218,7 +219,7 @@ fn main() {
link_lib("QuickControls2");
#[cfg(feature = "qtmultimedia")]
link_lib("Multimedia");
#[cfg(feature = "qtmultimediawidgets")]
#[cfg(all(feature = "qtmultimediawidgets", feature = "qtwidgets"))]
AdrianEddy marked this conversation as resolved.
Show resolved Hide resolved
link_lib("MultimediaWidgets");
#[cfg(feature = "qtsql")]
link_lib("Sql");
Expand Down
1 change: 1 addition & 0 deletions qttypes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//! | **`qtsql`** | Qt SQL |
//! | **`qttest`** | Qt Test |
//! | **`qtwebengine`** | Qt WebEngine |
//! | **`qtwidgets`** | Qt Widgets |
//!

#![cfg_attr(no_qt, allow(unused))]
Expand Down