Help answer threads with 0 replies.
Go Back > Blogs > rainbowsally
User Name


Rate this Entry

QT4 GUI testing and experiments (including sub-attaq and tooltips)

Posted 04-29-2012 at 12:43 AM by rainbowsally
Updated 08-06-2014 at 10:17 AM by rainbowsally (stuff like what? stuff like missing xml files happens (clarification))

Sorta back on track after some false starts and tweekage on the mc2 makfile creator...

Here's a few things that might be interesting that I cooked up while testing mc2 on QT examples and demos.

If nothing else you might be interested to see that *.pro files are NOT required to compile these things (there are some download links below).


If you want it, here's a utility to create a new ui file from scratch that will open with designer or creator when you click on it.

file: ~/bin/src/misc/new.ui (executable)

if [ "$1" == "" ]; then

cat << _EOF > $name.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <widget class="QWidget" name="Form">
  <property name="geometry">
  <property name="windowTitle">
Make a symlink to it in your HOME/bin folder to 'install' it. (See new.symlink in early blog entries, like around page 3 or 4, if you like these 'new.<name>' utilities and this system of installing in your ~/bin folder.

Again, this creates the initial ui file, it isn't the file itself.



I created a gui toolkit that worked well with suse 10 but not with suse 11. I call it FTL and it was based on the once and now again defunct fltk 2.0.

The main problem is that somehow the improvements between suse 10 and suse 11 clobbered the subpixel rendering of circles that I drew oversize and then scaled down for the final 'draw' operation. This works for actual images (still) in the newer openSUSE but not for scaled images that are drawn line by line in an offscreen pixmap.


Here's before and after drawing 2X scaled which worked in suse 10.

And here's an example in the QT examples that is called tooltips, but which I thought was less interesting for the tooltips than it was for the subpixel rendering which makes the circles so nice.



The sources are about half a meg and should compile pretty much out of the box unless your libs are in oddball locations. You may be able to edit the Makefile, or with mc2 you can edit the mc2.def file which isn't so finicky about 'separators' and such.

You may notice a couple of changes in the sources if you have the original example in your system. One is that we use a subdirectory for the sources and the other is that we precompile the resources, eliminating the QT_INIT_RESOURCE() macro usually set in 'main.cpp' (More on why we do this below.)

QT got subpixel rendering nailed. I'd like to see how. They call XRenderComposite() which I hadn't done. I used a more generic X call. And this is probably part of the solution, but it's not all of it.

Nevermind. That's my own gig. ;-)


So... now what?

Let's mess around a bit.

Here's sub-attaq from the demos folder that hadn't worked for me before. If you also had trouble getting it to compile, try this one. The problem? I was missing data.xml. I was able to manually add that file to my make-based installer's TREE and now it works.

Here's a copy reworked using mc2 that should work for you in case you did have similar problems with this one.

This too is about half a meg. See the README's in the downloads for how to 'make' them. (We need to generate the moc, uic, and qrc files in a separate 'make' target.)

Note that we are compiling the resources into the applications rather than loading them from the directory at run time. This is a bit redundant but the executable needs to be in the same directory with the sources if we don't do this.

QT_INIT_RESOURCES() in both of these apps has been commented out for this reason.

The makefiles were generated using mc2, but you don't need mc2 to 'make' or run them.

However, during this exercise I noticed that we need our mc2 -run qt4-ui switch to warn us when stuff like missing xml files happens.

mc2 v. 2.0.7 adds this ability.

Well... that's enough Computer Mad Science for one day, I guess.


Seriously, if those demos didn't work, especially sub-attaq, you might never have known it with the *.pro file and qmake system.
Posted in Uncategorized
Views 757 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 06:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration