Updating Qt, hehe.

Tonight I updated SASs TeamSpeak 3 server, and discovered that my TS3 client was too darn out of date to work with it, haha. After updating things, I also noticed in the nifty about dialog they shipped, that the version of Qt used, denoted the GNU LGPL v2.1.

It has been a good while since I updated Qt on my windows system, last time was about one year ago. So I dropped by Qt’s website to download an updated SDK, and also found that they had MinGW and Visual C++ 2008 library packages available. Last time I really focused on Qt/C++ development, Microsoft Visual C++ was just becoming supported by the Open Source Edition (OSE), having long been supported by the commercial editions of Qt.

In perusing the website, I noticed that GPLv3 is now also a supported license for Qt. They really have gone through a few licenses over the years, I still remember when the OSE was a chose between GPLv2 and their own Qt Public License agreement.

While I really hate doing cross platform development in C++, Qt is both the least painful widget toolkit I’ve ever seen, and really makes the process *a lot* less painful. Well, as less painful as dealing with template implementations between GNU/MS C++ compilers anyway.

It is note worthy that the SDK only includes the necessary library files to link using MinGW, the port of the GNU Compiler to Windows. So if you plan on using Microsoft’s compiler, you will want the vs2008 package, or the source code if you need to shoe horn into an older version.

One thing I like about all the *decent* operating systems shipping a system compiler on their install disk, that usually means pre-compiled packages will be in sync with your compiler. Microsoft Visual C++ is not quite so lucky, since being a separate product, most people shipping binary packages of libs/headers, usually support 7.1 or 8.0 instead of 9.0. Oh well, maybe when VC10 is released :-/.

Todo: Toolkit and Library madness

Examine for portability the following toolkits under these OSes: Windows NT, Mac OSX*, Unix-like.

*I sadly don’t have a Mac, although I would really love one. So a OSX binary of some form will have to pass.

GTK+ — C, C++, Perl, Python, Ruby, PHP, C#.NET (Java bindings also avail but seem to be gnome-centric)

Qt4 — C++, Perl, Python, Ruby, Java (C#.NET and PHP bindings seem to be questionable and only C++/Python and possibly Java bindings can be depended on).

WxWidgets — C++, Perl, Python, Ruby, Java, C#.NET

Swing and SWT would be considered if they were available under more languages !!!

Evaluate portable standard/add-on libraries to each language for the following capabilities:

String handling (they all do well in the language standard)
Regular Expressions (Only Perl and Ruby get this great imho)
XML Processing
Network programming — both sockets based API and protocol support (IMAP, POP, HTTP/S, FTP)
Database handling — must support MySQL, SQLite, and some form of flat file.
Basic compression and archive format support (e.g. tar; zip; gz; bz2; lzma)
Inter-Process Communication (IPC) methods and related process control (e.g. fork(), exec(), signal(), kill() type routine-families).
Ease of use and deployment


Build up a standard frame work of toolkits/libraries/etc that are portable across both my general operating environment and the various languages I use

Attempt to standardize myself on few languages rather then rubber banding between various programming languages + sh/awk/sed/friends

Ensure full development environments are available to me under FreeBSD 7 and Windows NT 5.1 (e.g. I can code from either machine and not change tools)

At least one language for scripting/prototyping and one for more efficient execution when implemented in that language (e.g. 1 interpreted + 1 compiled)

and try to stay sane along the way without writing a few libraries in the process >_>

Tired… I think my sleep/work patterns of late are starting to get to me :

Manged to get some time in on TG#1, even if it was some ‘solo’ dynamic assaults.

I’ve also gotten another module imported, and another that would be ready if I didn’t have to port it from using the Qt3 Support library… lol.

It shouldn’t take to much work to get the portconfig module ready for import but, my brain needs some rest :. And I’m stuck going back to work soon (an ~hour) on top of it 🙁

the nights antics

I was rather happy to see that SourceForges SVN services were back up to a decent speed, other wise I probably would’ve gone to bed instead of getting back to work :

I managed to finish the work on the project file, I had inhaled the qmake manual before dinner ;-). I knew exactly what I wanted, test works all been done in a ‘one lump sum’ directory… Which is the style that I really hate, to much crap to visually grep through when looking for parts of the project.

The build format that I desire is basically like:

Makefile -> top level, non recursive make
doc/ -> documentation files
dist/ -> files ready to install (all done)
obj/ -> object files and crap from moc / building docs, etc
src/ -> source code files
src/module/ -> source code files for module

Which is basically what I’ve setup, maybe I’m just spoiled by the layout of FreeBSDs source tree and build system… hehe.

I was quite happy to find that as usual, Qt makes life easier not harder xD. It only took the fine (if short) manual and a little bit of trial time to get more or less what I wanted out of it, all the better! Without having to worry about a recursive trail of makefiles. When it comes to recursive makes, I have no problem with the concept, I just don’t care much for it.

I figured that if I couldn’t get what I wanted out of qmakes project files that I would have to do things manually. I don’t really have a problem with hand crafting makefiles but I really prefer not to have to maintain them, let along risk leaving something behind that needs a Bachelors of GNU Makeology to understand fully.

I did manage to get one module (essentially) imported into the SVN tonight and I’ve almost got another ready to go in. But before I commit it, I want to get the things refresh() slot sorted out. To do that, I just need to clear the m/v I guess but that can wait until tomorrow’ish.

As I often have said, laptops make poor pillows !

There’s about 5 more modules to import, as soon as they are adapted and ready to roll that is. Right now I’m in advantageous territory code wise but as usually, my working environment is, uhh… “Hostile” to say the least to productivity.

Maybe if anyone in this fuckin’ family knew an ounce of computers, let along programming, the bastards would let me work in peace rather then in pieces !!!!!!!

misc thoughts

Well some progress, aside from spending an embarrassing amount of time trying to find a problem starring me right in the face shouting “this is wrong you moron!”, I suppose exhaustion can do that…

To be perfectly honest I think one of my biggest problems is my multi-lingual nature when it comes to programming. In the past couple days, I’ve used Bourne (with best buddies SED & AWK of course), Perl, Ruby, PHP, and C++ for various tasks.

In a large way, a language is just pretty much a language to me, a standard syntax, types, and subroutines if you will. Generally I think about solving problems in a way that doesn’t really connect to a specific language. Sure I tend to write and think in a language of the moment but at the end of the day, the implementation is the language specific part — not the solution.

When it’s something that takes me a bit of thought, I usually write it done in a form of pseudo code that relates to how I read code.

Then start thinking about that, i.e. it’s behavior: I dislike needing debugging aids when a brain will suffice. Then I start thinking about how to implement it, which often tends to lead to what language I’ll be using if not already knee deep in it.

For example, when it comes to regular expressions I very, very greatly prefer Perl and Ruby for such tasks. Python in particular has always felt (to me) a bit chunky at regexes compared to Perl but to each their own methods. Heck, a lot of times a scratch and run Perl script is my way of testing regular expressions for things.

Tonight I needed to figure out how to process a programs output, I quickly found the QProcess class to be increasingly *annoying* so I threw it out in favor of popen() and the usual methods — works like a charm. Then took a quick sample of the programs output, wrote a perl script to handle the operations upon it that was needed.

Then used the QRegExp and QString classes to implement the program using those regular expressions: skipping the compile time frustrations and indexing issues. Then proceeded to expand it into something able to meet my required behavior, after checking enough scenarios to validate it (to me). Then tested that to make sure it still behaved properly and moved on to using it to work on the next problem.

I’ve been using C++ a lot lately, really odd because I mostly quit using it after picking up C and Ruby a couple years ago lol.

0400, time for bed… but first it’s snack time!!!

believe it or not but a few hours of working on the computer has a few side effects ^_^

Recent activities.

Havn’t had a lot of spare time lately :

Survived my 20th birthday on the 20th, makes me wonder if I’m starting to get old in my own way lol.

My brother called and wished me a happy birthday, was good to talk with him even if I had to put up with a ‘lecture’ 8=). I know the old axim is “those who can’t do, teach” but in my families case it is lecture >_>.

Night before my birthday I managed to polish off one of my favorite burgers from Ruby Tuesdays. I remember the first time I had one, hehe a few years back I was the only guy involved in a project. So the girls had to throw a birthday party and what else but The Ultimate Colossal Burger xD

They always did know how to throw a party lol.

Ma also made 2lbs of Chili, so I’ve been feasting on that for the past couple days, hmm now that I think of it.. A little chili would hit the spot about now ;).

I spent most of my birthday eating, sleeping, and coding — three good things, especially since sleep is a premium for me +S. I ain’t done much of anything in C++ in about 3 years, sad considering November will be my fourth anniversary. But I’ve really been enjoying the C++/Qt4 work of late, even better I’ve got suitable development environments on my laptop and desktop. Lunch was a trip to the best all you can eat joint in town, so that went well hehe.

Still, it’s all overshadowed by one thing… But I guess that’s a different subject.

I’ve managed to get a bit of training in this weekend, been concentrating on the fundamentals of room clearing for Jonsi’s training. One nice thing about teaching it, I’ve been doing it enough in the virtual world, that I parts of it flow into the real world lol.

Ok, so is it that bad if you tend to stack on doors and button-hook entries ? haha

Started work today on a diagram for a new swat4 map, The [SAS] Killhouse Redux. I’ve got over 25 rooms and two floors with concepts for adding another wing on the first floor. What I like the most about the design, it’s trivial to build it in bits and pieces. Level 1As first wing, then the other wing or Level 2A, etc. My original “dream” for the ultimate training facility included like a 5-6 floor shooting house but no map maker got into the project.

The only big problem is me and the Unreal Editor used mix like water and oil. I should be happy though, as crappy as SwatEd is it really is less bothersome then the UnrealEd build shipped with Raven Shield. Although I’m more used to the Rvs build… At least the S4 one doesn’t crash so often!

I can do almost anything I set my mind to, it’s just a matter of time. Tomorrow I need to inhale one of the tutorials and set to work on more of the map. The main problem atm is adjusting the objectives, although I reckon I could always make a room in the middle of no where full of tangos lol. The old [SAS] Killhouse in RvS that we used to use before I even got here, had a lone tango hidden behind boxes. But that was more so because of issues with the game design, Swat4 is a little less, ehh irksome.

Today I also got some time on the SWAT4:TSS server for the first time in a good while, I really miss that game lol. The only bad thing I can say, is the MP5s don’t support full auto. I’d rather have a trusty MP5N but hey, the devs had to make it more ‘balanced’ :. The UMP.45 fires at about 300 RPM on their own scale and on full auto, while the MP5 is limited to three round bursts as respective alternatives to semi automatic.

I really prefer full auto because I can control the bursts. In RvS, I often like to use the MP5/10A2 because the way it was implemented. You can’t hit shit past about 30 metres and if you fire more then 2 rounds at a time, you won’t (consistantly) hit shit to start with ! The FAMAS G2 also has such a high rate of fire, that it’s great fun to put on full auto and try to fire one round from it per trigger pull.

SWAT4 has one of the worst simulations of ballistics I’ve ever seen but, Rvs has good shooting but the worlds most unreal physics.

Tomorrows plans, map making and training ops. With how long it’s been since I’ve really played SWAT4, I think I should take some drill time to work on my usual reflexive plan.

3-round burst to centre mass then follow up with a double tap or another burst to the noggin.

Me, I fire a lot of rounds per kill — because I keep firing till the f****er goes down. The advantage of video games is, once they die they start to fall over dead (realistically or not). The disadvantage is unlike the real world, getting shot doesn’t have much effect on the enemy. At the best you might jar their shots (rvs) or stun them briefly (swat4) for another follow up shot.

What I really would love to do some day, is set up sensors on the monitor and a laser pointer on a model weapon. And have the sensors on the screen detect the movements of the laser beam across their own beams and use that to generate mouse movement-input for the operating system.

That would make aiming a lot more reflexive then a mouse lol.

Does Python or PyQt3 have a pox on C++?

This is illogical as I’ve seen Python get.

Terry@dixie$ cd code/C++/src/qsm                                           0:11
Terry@dixie$ python 0:11
Python 2.5.2 (r252:60911, Apr 17 2008, 16:34:02)
[GCC 3.4.6 [FreeBSD] 20060305] on freebsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> from qt import *
>>> QDialog
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'QDialog' is not defined
Terry@dixie$ cd $HOME 0:11
Terry@dixie$ python 0:11
Python 2.5.2 (r252:60911, Apr 17 2008, 16:34:02)
[GCC 3.4.6 [FreeBSD] 20060305] on freebsd6
Type "help", "copyright", "credits" or "license" for more information.
>>> from qt import *
>>> QDialog
<class 'qt.QDialog'>

Maybe there is a reason for this and I’ve just got to much of a headache from today to notice it, but WTF man? lol. It’s almost as if Python has a pox on running a script in that directory :

I wanted to test an idea for a dialog quickly, so I started a new python script. Only to have NameError’s whenever trying to reference a member of the qt module. So i copied over one of the py-qt3 example programs that came pre-installed and tried that, same barfing results.

Then I tried interactively with python, no go — changed directories to home and tried both, and they fucking work !!!!

I don’t know whether I should laugh out loud or start hex editing maliciously lol.

Spent most of the dy with a headache and killing time in the servers..

I did manage to get time to read most of the documentation on QT’s I18N & L10N features and it actually seems to be a lot easier then I thought.

I knew there was some thing I liked about the folks at Trolltech ^_^

As far as coding for tonight, I’m not sure what I’ll be working on.. All I know is my paper work is late and the dead lines in two days… So I think that has priority if my family would ever leave me be…

I don’t really know what is worse, taking aspirin so often you get stomach ulcers or putting up with the results of life here =/

Qute I/O

Been meandering about with Pythons subprocess and various IPC (inter Process Communication) focuses modules tonight. When I remembered I had noted that QT and KDE had classes for working with processes.

Looked up the class in the documentation and played with it. Then I found a small example program that they included. Here is the QT written example using C++, the primary language.

** $Id: qt/process.cpp 3.3.7 edited Aug 31 2005 $
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.

#include <qobject.h>
#include <qprocess.h>
#include <qvbox.h>
#include <qtextview.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <qmessagebox.h>

#include <stdlib.h>

class UicManager : public QVBox

~UicManager() {}

public slots:
void readFromStdout();
void scrollToTop();

QProcess *proc;
QTextView *output;
QPushButton *quitButton;

// Layout
output = new QTextView( this );
quitButton = new QPushButton( tr("Quit"), this );
connect( quitButton, SIGNAL(clicked()),
qApp, SLOT(quit()) );
resize( 500, 500 );

// QProcess related code
proc = new QProcess( this );

// Set up the command and arguments.
// On the command line you would do:
// uic -tr i18n "small_dialog.ui"
proc->addArgument( "uic" );
proc->addArgument( "-tr" );
proc->addArgument( "i18n" );
proc->addArgument( "small_dialog.ui" );

connect( proc, SIGNAL(readyReadStdout()),
this, SLOT(readFromStdout()) );
connect( proc, SIGNAL(processExited()),
this, SLOT(scrollToTop()) );

if ( !proc->start() ) {
// error handling
QMessageBox::critical( 0,
tr("Fatal error"),
tr("Could not start the uic command."),
tr("Quit") );
exit( -1 );

void UicManager::readFromStdout()
// Read and process the data.
// Bear in mind that the data might be output in chunks.
output->append( proc->readStdout() );

void UicManager::scrollToTop()
output->setContentsPos( 0, 0 );

int main( int argc, char **argv )
QApplication a( argc, argv );
UicManager manager;
a.setMainWidget( &manager );
return a.exec();

#include "process.moc"

Needless to say, I am not really a fan of C++ at times ^_^. I translated the example into Python for a simple test and I like it quite a bit.


# I translated the example: process/process.cpp to python and boy do I love qt!
## Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
## This file is part of an example program for Qt. This example
## program may be used, distributed and modified without limitation.

import sys
from qt import *

class UicManager(QVBox):
def __init__(self):
self.output = QTextView(self)
self.quitButton = QPushButton(self.tr('Quit'), self)
self.connect(self.quitButton, SIGNAL('clicked()'), qApp,

# QProcess related code
self.proc = QProcess(self)


self.connect(self.proc, SIGNAL('readyReadStdout()'),
self.connect(self.proc, SIGNAL('processExited()'),

if not self.proc.start():
sys.stderr.write('fatal error could not start uicn')

def readFromStdout(self):
'read in proc data which may be in chucks'

def scrollToTop(self):

if __name__ == "__main__":
a = QApplication(sys.argv)
manager = UicManager()

QProcess is nice but I’m not sure about using enormous amounts of data though yet.


As a test I set up the Python script to pass a ‘ls -R /’ basically causing it to list all files on all mounted file systems. The code to scroll back to the top caused major lock up to the program and some performance loss for the entire laptop: probably screaming at being down to about a 150MB of swap space left.

Removing that and closing programs so only konsole running it and top + amarok playing music was running. At times top reported free memory over < 1MB about 30-40% swap usage. However without the scroll to top thing gone it didn't cause any real performance for the laptop; probably because there was much less swap usage used up. As a test I ran ls -R / direct afterwards and while it did pile on the stats in top, it still kept to about 50MB free and even less swap usage on the displays.
So far I think it would probably work for whatever is needed as long as the computer continues to provide adequate memory and the kernel doesn’t have a hissy fit about the pipes and things in the background.

Enter the Dragon

Well, so for work goes well for day one.

I’ve spent most of the day working on the configuration system, at this point it would be a lot easier to have a configuration file, so I set about to work with Pythons SafeConfigParser class and the format of the config file and options, e.t.c. There is still more to do but it is a great start, especially considering that I am not entirely comfortable with OOP under Python

I’d say greater then half the code for installing and updating the ports tree is done enough for further testing, the only issue right now is the reaction to errors sup’ing or portsnaping.

I am some what tempted to try and have a wrapper of sorts that will abstact the issue of using QT or KDE specifics but I don’t think there would be any point. I need to dig deeper into the PyQT/PyKDE, QT, and KDE documentation soon so I can work more gui_error.py.

widets ? qt : kde;

It would be nice to use as many elements of the KDE bindings as possible, so it fits better with systems running KDE, yet it would also be nice to keep to the QT bindings more strongly so it is less tied to KDE.. In the end it will probably be which ever I’m more comfortable with.

My primary goals in the coming days is to finish the options and errors modules while I start work on the ‘searchlet’, which should handle searching through ports. Until a concreate mock-up can be made of the entire main window, I think I should keep the search stuff as far away from the rest of the program as I can.

Work on the searchlet as I call it, shouldn’t be to hard to keep self-contained since I prefer to work on smaller pieces and properly prototype things when I can, I’m not a real fan of monolithic masses =

Basically 7 tenths of that battle will be wrapping my head around working with the KListView and QListView widgets. Once I’ve figured that out, it’ll be simple enough (I hope) to figureout how to make it work with displaying a search through ports. It’s just I need to get a grip on the ListView widgets before I can do that lol.

Either way, I think I have done enough for one day… 0700 Zulu Time and it would probably be nice to have a little sleep before work tomorrow 0.o

A little horsing around before bed, not pretty but considering I don’t know QT from a hole int he ground… And I’m doing this with C++ documentation for Python, I think it’s a nice ‘Hmm, how do you make a QListView object?” test:

#!/usr/bin/env python
# Neo Ports Manager (NPM) -- refer to the LICENSE file for terms and conditions


import sys, os
from qt import *

def main( argc, argv ):
a=QApplication( argv )
listViews.setCaption("Qt Example - Listview") # Sets window title
# Add some columns to the list view
listViews.addColumn('Qualified name')
# element is how to create a new list view item for display
element = QListViewItem(listViews, 'qName', 'namespaceURI')
# Now lets populate an array of items into view
els=[ [listViews, 'dir1', 'descr1'], [listViews, 'dir2', 'descr2'],
[listViews, 'dir3', 'descr3'] ]
for j in els:
QListViewItem(j[0], j[1], j[2])
# And sort it descending by col 1
listViews.setSorting( 1, False )


# draw & exec

if __name__ == "__main__":
main(len(sys.argv), sys.argv)

I don’t like that QListViewItem(j[0], j[1], j[2]) line but I was trying to translate from the C++,

for ( int i = 0 ; i < attributes.length(); i++ ) {
new QListViewItem( element, attributes.qName(i), attributes.uri(i) );

And I’ve yet to figure out how to better cook this up, still reading the docs here…