LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Blogs > rainbowsally
User Name
Password

Notices

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)
Code:
#!/bin/sh

if [ "$1" == "" ]; then
  name=form1
else
  name=$1
fi

cat << _EOF > $name.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Form</class>
 <widget class="QWidget" name="Form">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
 </widget>
 <resources/>
 <connections/>
</ui>
_EOF
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.

---------------------

Now...

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.
http://rainbowsally.org/rainbowsally...ed-drawing.png

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.

screenshot:
http://rainbowsally.org/rainbowsally...s-tooltips.png

download:
http://rainbowsally.org/rainbowsally...ooltips.tar.gz

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.

http://rainbowsally.org/rainbowsally...b-attaq.tar.gz

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.
http://www.linuxquestions.org/questi...eration-34648/

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 456 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 09:39 PM.

Main Menu
Advertisement

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