Skip to main content

Ralsina.Me — Roberto Alsina's website

Where IUP/Qt is right now

It has a de­cent back­end, even if it's lim­it­ed.

Not all wid­gets are im­ple­ment­ed, but they are easy to ad­d. Not all at­tributes are im­ple­ment­ed, but they are even eas­i­er.

And it can show rather com­plex win­dows, too:

http://lateral.blogsite.org/static/diup2.png

Now I remember why I don't like C++

I have refac­tored IUP/Qt in­to a love­ly ob­ject hi­er­ar­chy. And I now re­mem­ber why I dis­like C++.

Here's the ba­sic prob­lem (code may be wrong, I don´t have the bro­ken ver­sions any­more):

I have a base class IOb­jec­t, that has stub set­ter­s/get­ters for all the IUP at­tributes.

For each kind of wid­get, I cre­ate a class that in­her­its from IOb­ject and the match­ing Qt wid­get (ex­am­ple: QDi­alog).

These have to be hooked in­to an Ihan­dle struc­ture through the use of a void * (re­mem­ber, that's C, I have that too ;-)

Now, this was my first naive ap­proach:

Ihandle *n;
IQDialog *d=new IQDialog();
n->handle=d; //handle is a void*

That com­piles ok. How­ev­er, when you try to call a d mem­ber lat­er (and I know I am us­ing old C cast­s... they had worked for me un­til to­day!) ...

((IObject *)(n->handle))set_title("Title here");

Blam­mo, seg­fault. Why? Be­cause in one of the as­sign­ments to/from void *, the point­er for some rea­son starts to point else­where.

Here´s what Glip­tic at #C++ sug­gest­ed, and it does work:

Ihandle *n;
IQDialog *d=new IQDialog();
n->handle=static_cast <void *>(static_cast < IObject *> (d));

Right, I have to cast it twice.

And here is how you get it back:

(static_cast < IObject * >(n->handle))->set_title ("Some title");

Is­n't this just ridicu­lous­ly weird for any­one com­ing from any oth­er lan­guage?

Or am I miss­ing some­thing com­plete­ly?

But the good news is, it works ok, and the Qt back­end now has a de­cent struc­ture to hack on.

IUP/Qt preview

Ok, here is ver­sion 0.0.1 of my Qt4 back­end for IUP . It's not very good, but a bunch of things work. A whole bunch more do not, of course.

I am show­ing this just be­cause I want to re­write it, be­cause I no­ticed that I am writ­ing it like it was Mo­tif stil­l, and I must un­der­stand this is ac­tu­al­ly C++ and Qt code ;-)

Us­ing it along with DI­UP you can write sil­ly Lin­ux/Win­dows/­Mac GUIs from D, or you can use C. No LUA yet.

You can down­load it here (click on the "Free" but­ton and wait a while).

You will need Qt4 and qmake to make it work.

IUP/Qt is advancing

I have call­backs (some), ge­om­e­try man­age­men­t, LED files load­ing (re­source files) and it seems no hard parts are left.

That would mean the re­main­ing work is routi­nary, even if it's a large amount of it.

It's nice that I can switch back and forth be­tween the Mo­tif and Qt im­ple­men­ta­tions just by set­ting LD_LI­BRARY_­PATH to com­pare :-)


Contents © 2000-2024 Roberto Alsina