| |
| Posted by evilrat in reply to Josh Dredge | PermalinkReply |
|
evilrat
Posted in reply to Josh Dredge
| On Tuesday, 27 October 2020 at 11:46:02 UTC, Josh Dredge wrote:
> Hi all, I'm completely new to D and while I'm not new to programming in general, I mostly do web development,
Welcome! If by web development you also have back-end programming then you should be like 50% know how desktop programming works.
>
> I'm looking at learning D, but would like to stick with what I know on desktop in terms of event-driven GUI based applications.
Just an advice, Qte5 isn't well maintained, the other alternatives such as 'dlangui' also seems abandoned, so basically the only maintained UI library here is gtk-d, but there was recently a nice tutorial series written about it.
Though I admit I've kind of dropped from the D for the 6 months.
> I have Visual D installed, as well as QtCreator and was hoping to be able to use Qt with D. I'm happy without any GUI builder for now, but still need a working GUI library! Qte5 looks fine but need to figure out how to implement it.
>
> I've installed D in "C:\D" (Windows 10 x64).
> I've installed Qte5 in "C:\D\Qte5".
>
> Quite simply typing "import Qte5;" into the code doesn't work (module not found), and I'm not sure how to make sure the library is correctly installed and reference. Is there a setup guide? I found one on Youtube but it didn't really explain anything. What's the way to do it?
>
First, since you are already trying to work with C++ (Qt is a C++ framework after all) under the hood you will likely need to install MS build tools and Windows SDK, this will get you missing libraries and first-class support for building native binaries.
Now to the point - 'module not found' is a compiler message that tells you 'there were no such module in module search paths', with dmd you can point compiler to look for qte5 dir with -I flag (or recently -i to also build these), then you also need to pass built .lib OR .obj files for Qte5 that contains compiled code otherwise you'll see link errors.
So for building your code it is better (for now) to use 'dub'(official build system & package manager, usually ships with compilers)
Let's just make a new dub project and add qte as dependency (since it's already on dub registry)
- Let's create a new project in current working directory named MyAwesomeProject, just hit enter for all questions
$> dub init MyAwesomeProject
- Now go to this folder
$> cd MyAwesomeProject
- Clone qte5 repo to your project (or download and unzip)
$> git clone https://github.com/MGWL/QtE5
- And let's add Qte5 dependency(btw you can see it here https://code.dlang.org/packages/qte5), note that it is completely unrelated with our cloned repo
$> dub add qte5
- Now open your dub.json in your project and replace dependency path (we do this because it is semi-abandoned, and last published version was 4 years ago, even though there was some recent activity on master branch) so your dependency section should like this
"dependencies": {
"qte5": { "path" : "./QtE5" },
},
- If you try to build it right now it will error, so we have to "fix" it, so go to QtE5 folder, open dub.json and remove 'sourceFiles' section, it should build just fine without it.
- Copy example code from QtE5/example/example.d and replace your source/app.d with it
- Build using dub
$> dub build
- Done! Now if you have Qt5 installed and present in you system %PATH% environment variable (or copied DLL's next to executable) I assume it should work. (since I don't have I can't test if it actually works)
- (Optional) It is possible to (re)generate VisualD project after you modify your dub project configuration, (additionally it can take any other build options such as --arch or --config, but ultimately it generates exactly one variant of all possible arch/config flavors)
$> dub generate visuald
Where to get packages?
D packages and dub (note though that not everyone publish it here, some people have extra fancy stuff on their github/gitlab) - https://code.dlang.org/
|