cat /dev/maxilys

A glance in the mind of a KDE/Linux developer to see how ideas turn into code.

2006-02-24

KDE: Persistance of frustration

Just two words to say that I retrieved the 3rd app using QToolBox, it's KPDF. But it didn't help me to do what I want with these widgets. The more I work on them, the more frustrated I grow.

Meanwhile, I did something that I found more satisfying: Code cleansing! When you work with Qt geometry, it's like entering a jungle of parentheses. The worst are those empty parentheses everywhere that bloat your code. Serenity really deserves a version increase after what I did.

Whenever possible, I inserted a block of code resembling the following:

int left, top, width, height;
that.rect(&left, &top, &width, &height);
int right, bottom;
that.coords(&left, &top, &right, &bottom);

So, instead of the bloating that.left(), I can just use left. And the same apply to left, top, width, etc. That removes thousands of parentheses --I didn't count.-- and the code become more legible to an human eye.

After that, I could keep on stumbling around the toolboxes. I wasn't really satisfied. I wanted to get closer from the regular tabs design, with separators in between the tabs. For that, I need at least to know if the toolbox tab I'm drawing is the first or the last. In both cases I must not draw a separator in between the toolbox and the "outside".

Here came the frustration. It seems totally impossible to know which toolbox tab you're working on. This is driving me nuts. There is a way to get the widget corresponding to a position. It works only once when a toolbox tab is selected, then the tabs seems to move out of the toolbox because that's what Qt tells me. I tried another way: Get the list of the children of the toolbox and retrieve which one corresponds to the rectangle I'm allowed to draw in --that's the widget I'm interested to know. Oh, it works... except that Qt tells me that the children of the
toolbox I just got don't exist. That can't be, but who cares? So it fails too.

I don't know, maybe there's something I'm too stupid to understand and I'll crawl back here on my knees to beg for forgiveness. In the mean time, I suffer the sweet pain of frustration... and I cry to everyone who wants to listen: Why, oh why? ;-)

0 Comments:

Post a Comment

<< Home