www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - DQt: Qt bindings using extern(C++)

reply Tim <tim.dlang t-online.de> writes:
DQt contains new experimental bindings for using a subset of Qt 
with D.
Qt is a library for writing cross-platform graphical user 
interfaces.
Currently bindings exist for the Qt modules core, gui and 
widgets. The
bindings use extern(C++) and don't need any wrapper in C++. They 
are
based on Qt 5.15.2 and tested on Linux and Windows, but need a dmd
compiled from master for Windows.

For more details see the README.md in the repository:
https://github.com/tim-dlang/dqt

It is also available with dub:
https://code.dlang.org/packages/dqt
Dec 05 2021
next sibling parent reply russhy <russhy_s gmail.com> writes:
Thanks for sharing!

Don't forget to settopics (D, QT, binding, ui, gui for example) , 
it's in the same menu as your "About" one

This helps discoverability on github a lot!
Dec 05 2021
parent Tim <tim.dlang t-online.de> writes:
On Sunday, 5 December 2021 at 14:13:21 UTC, russhy wrote:
 Thanks for sharing!

 Don't forget to settopics (D, QT, binding, ui, gui for example) 
 , it's in the same menu as your "About" one

 This helps discoverability on github a lot!
Thanks for the suggestion. I have added some topics.
Dec 05 2021
prev sibling next sibling parent reply user1234 <user1234 12.de> writes:
On Sunday, 5 December 2021 at 12:54:21 UTC, Tim wrote:
 DQt contains new experimental bindings for using a subset of Qt 
 with D.
 Qt is a library for writing cross-platform graphical user 
 interfaces.
 Currently bindings exist for the Qt modules core, gui and 
 widgets. The
 bindings use extern(C++) and don't need any wrapper in C++. 
 They are
 based on Qt 5.15.2 and tested on Linux and Windows, but need a 
 dmd
 compiled from master for Windows.

 For more details see the README.md in the repository:
 https://github.com/tim-dlang/dqt

 It is also available with dub:
 https://code.dlang.org/packages/dqt
no dynamic cast problems (https://issues.dlang.org/show_bug.cgi?id=21690)?
Dec 05 2021
parent Tim <tim.dlang t-online.de> writes:
On Sunday, 5 December 2021 at 17:11:09 UTC, user1234 wrote:
 no dynamic cast problems 
 (https://issues.dlang.org/show_bug.cgi?id=21690)?
I did not see this problem. Qt uses a custom implementation for dynamic casts of objects inheriting from QObject, which is independent from C++ dynamic_cast. See function qobject_cast: https://doc.qt.io/qt-5/qobject.html#qobject_cast
Dec 05 2021
prev sibling next sibling parent zjh <fqbqrr 163.com> writes:
On Sunday, 5 December 2021 at 12:54:21 UTC, Tim wrote:
 DQt contains new experimental bindings for using a subset of Qt 
 with D.
It would be nice if there were bindings for `sciter, wxwidget`, etc.
Dec 05 2021
prev sibling next sibling parent reply MGW <mgw yandex.ru> writes:
On Sunday, 5 December 2021 at 12:54:21 UTC, Tim wrote:
 DQt contains new experimental bindings for using a subset of Qt 
 with D.
 Qt is a library for writing cross-platform graphical user 
 interfaces.
 Currently bindings exist for the Qt modules core, gui and 
 widgets. The
 bindings use extern(C++) and don't need any wrapper in C++. 
 They are
 based on Qt 5.15.2 and tested on Linux and Windows, but need a 
 dmd
 compiled from master for Windows.

 For more details see the README.md in the repository:
 https://github.com/tim-dlang/dqt

 It is also available with dub:
 https://code.dlang.org/packages/dqt
Nice work! Did you use any converter to describe classes automatically, or is it all manual?
Dec 06 2021
parent reply Tim <tim.dlang t-online.de> writes:
On Monday, 6 December 2021 at 08:28:58 UTC, MGW wrote:
 On Sunday, 5 December 2021 at 12:54:21 UTC, Tim wrote:
 DQt contains new experimental bindings for using a subset of 
 Qt with D.
 Qt is a library for writing cross-platform graphical user 
 interfaces.
 Currently bindings exist for the Qt modules core, gui and 
 widgets. The
 bindings use extern(C++) and don't need any wrapper in C++. 
 They are
 based on Qt 5.15.2 and tested on Linux and Windows, but need a 
 dmd
 compiled from master for Windows.

 For more details see the README.md in the repository:
 https://github.com/tim-dlang/dqt

 It is also available with dub:
 https://code.dlang.org/packages/dqt
Nice work! Did you use any converter to describe classes automatically, or is it all manual?
I wrote a converter, but also had to make many manual changes.
Dec 06 2021
next sibling parent MGW <mgw yandex.ru> writes:
 I wrote a converter, but also had to make many manual changes.
I realized that without a converter you can't do this kind of volume ... I'm thinking about a converter too, I keep thinking and thinking (((( Please - more comments in the examples, a lot of non-obvious constructions. The library is great, I really liked it!
Dec 06 2021
prev sibling next sibling parent zjh <fqbqrr 163.com> writes:
On Monday, 6 December 2021 at 16:14:03 UTC, Tim wrote:

 I wrote a converter, but also had to make many manual changes.
It would be interesting to have a `C++/rust` general-purpose converter.
Dec 06 2021
prev sibling next sibling parent reply MGW <mgw yandex.ru> writes:
Can you explain in more detail some points that are difficult for 
me:

widgets/label.d file. I see a C++ mapping of class QLabelPrivate 
to structure D
extern(C++, class) struct QLabelPrivate;
this makes sense.

I see below an implementation of a class D named QLabel
class /+ Q_WIDGETS_EXPORT +/ QLabel : QFrame
in which I see calls to methods of the QLabel class.

I don't understand at what stage (where exactly) the mapping
QLabelPrivate structure methods onto QLabel methods.

I expected to see something like:
QLabelPrivate dd = QLabelPrivate(...);
and then
dd.MetodsQLabel(...)

Can you explain this place in more detail.
Dec 06 2021
parent Tim <tim.dlang t-online.de> writes:
On Tuesday, 7 December 2021 at 06:33:18 UTC, MGW wrote:
 Can you explain in more detail some points that are difficult 
 for me:

 widgets/label.d file. I see a C++ mapping of class 
 QLabelPrivate to structure D
 extern(C++, class) struct QLabelPrivate;
 this makes sense.

 I see below an implementation of a class D named QLabel
 class /+ Q_WIDGETS_EXPORT +/ QLabel : QFrame
 in which I see calls to methods of the QLabel class.

 I don't understand at what stage (where exactly) the mapping
 QLabelPrivate structure methods onto QLabel methods.

 I expected to see something like:
 QLabelPrivate dd = QLabelPrivate(...);
 and then
 dd.MetodsQLabel(...)

 Can you explain this place in more detail.
QLabel is also extern(C++), because the top of the file has "extern(C++):". Most methods in QLabel are directly implemented in the Qt library. Some are also implemented in D. For example QLabel.setText has a wrapper accepting the text without ref, so it can be called without creating a temporary variable. QLabelPrivate is used internally by Qt. This declaration is actually unused in the bindings. Many Qt types have a pointer to private data. New versions of Qt can then change the private data without changing the ABI between Qt libraries and applications. The constructor of QLabel creates an instance of QLabelPrivate and passes it to the constructor of the parent class (https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qlabel.cpp.html#213). QObject stores it then as d_ptr.
Dec 07 2021
prev sibling parent reply LorenDB <computersemiexpert outlook.com> writes:
On Monday, 6 December 2021 at 16:14:03 UTC, Tim wrote:
 I wrote a converter, but also had to make many manual changes.
Can we see the converter source? I'd be interesting in both looking at the code and also seeing if I can modify it to work with another library (i.e. Wt).
Dec 09 2021
parent reply Tim <tim.dlang t-online.de> writes:
On Friday, 10 December 2021 at 02:35:12 UTC, LorenDB wrote:
 Can we see the converter source? I'd be interesting in both 
 looking at the code and also seeing if I can modify it to work 
 with another library (i.e. Wt).
I have not released the converter yet. It is currently not very user friendly and needs many manual changes to the result, which I want to improve. It also has Qt specific parts. Qt does not use many types from the C++ STL or new C++ features in the API. This makes the bindings for Qt a bit easier, because only types from Qt are necessary.
Dec 10 2021
parent reply LorenDB <computersemiexpert outlook.com> writes:
On Friday, 10 December 2021 at 17:38:56 UTC, Tim wrote:
 I have not released the converter yet. It is currently not very 
 user friendly and needs many manual changes to the result, 
 which I want to improve. It also has Qt specific parts.
I will definitely be watching for the release of the converter code! Today I read through the D tour, so I now feel like I have a fairly good grasp of the language and am ready to start doing things with D instead of with C++, which means that I am doubly excited about getting DQt to work with all of Qt.
 Qt does not use many types from the C++ STL or new C++ features 
 in the API. This makes the bindings for Qt a bit easier, 
 because only types from Qt are necessary.
Maybe Qt 5 doesn't use lots of new C++ features, but Qt 6 may be harder to generate bindings for since it requires C++17 instead of C++98. Anyway, if you ever want some extra help with this project, I'd be glad to lend a hand!
Dec 10 2021
parent evilrat <evilrat666 gmail.com> writes:
On Saturday, 11 December 2021 at 00:47:56 UTC, LorenDB wrote:
 On Friday, 10 December 2021 at 17:38:56 UTC, Tim wrote:
 I have not released the converter yet. It is currently not 
 very user friendly and needs many manual changes to the 
 result, which I want to improve. It also has Qt specific parts.
I will definitely be watching for the release of the converter code!
For generic C++ code you can try my generator (yes it does code conversion, not just signatures), it handles like 80% of the job, the rest 20% is manual fixing signatures and code here and there, however newer C++ features is not yet covered. https://github.com/Superbelko/ohmygentool
Dec 11 2021
prev sibling parent LorenDB <computersemiexpert outlook.com> writes:
On Sunday, 5 December 2021 at 12:54:21 UTC, Tim wrote:
 DQt contains new experimental bindings for using a subset of Qt 
 with D.
 Qt is a library for writing cross-platform graphical user 
 interfaces.
 Currently bindings exist for the Qt modules core, gui and 
 widgets. The
 bindings use extern(C++) and don't need any wrapper in C++. 
 They are
 based on Qt 5.15.2 and tested on Linux and Windows, but need a 
 dmd
 compiled from master for Windows.

 For more details see the README.md in the repository:
 https://github.com/tim-dlang/dqt

 It is also available with dub:
 https://code.dlang.org/packages/dqt
Wow, this looks really cool! I have actually been holding back from learning D simply because it is hard to bring Qt with me. I did get dqml and DOtherSide set up yesterday, so I'm working my way through the D docs now, but this looks like it has potential to be more than just a wrapper around loading QML and interfacing D classes to QML. Here's hoping you are successful in getting DQt to extend to cover all of Qt instead of just a few modules! :) If I felt like I had enough D knowledge, I might try lending a hand, but I am unfortunately not there yet :(
Dec 09 2021