Note when compiling a Qt App on windows

This is a reminder to myself, after I’ve done a make dist-clean on Linux, and have brought the folders to my windows box, I don’t need to do


    qmake -project


as the project files already exist and this just wipes the necessary settings, instead I just need to do





I wasted 90 minutes trying to puzzle out why my Windows install of Qt wasn’t finding opengl  and was failing on a QMessageBox::information.

Good news Dave has found the internet, bad news I think his head has melted.

Back to school tomorrow. Cry

Old Blog Entries

When I upgraded this site to Drupal, I added some blog entries which I’d done on my laptop whilst on holiday in Inverness, but not uploaded to the web:

    * Layouts in Qt
    * CppUnit: Some More Discoveries
    * CppUnit Starting Out

All entries prior to this starting from the one just entitled Amos on 8/4/2005 were from my previous blog (also at this site address) which was Pivot based.

I’ve just been looking at the Wayback Machine hosted at the Internet Archive, and found the entries for the previous blog which I had encoded by hand, so I’m going to add these in too, they’re dated between 18/2/04 and 30/9/04 but have no titles so I’ll have to make these up as I go.

Adding them now.

I am Knackered!

We came back from Scotland last Sunday, and since then I’ve had a few days to do some work, and most evenings but I’m getting nowhere. I’ve not slept well all week and as a result, I’ve just been too brain dead to do anything constructive towards my project. I know exactly what I need to do first, that is decide on the exact interface for the Qgl base class to inherit from and test an implementation of it using CPPUnit and the QTest class. Tomorrow I think I might be able to have a go.

Instead of doing this constructive work I’ve been faffing as usual, although I have managed to end up with some useful stuff even if it doesn’t help my project along. I’ve set up this website to be Drupal based finally, and ported all of my previous blog posts over including photos (although I ended up installing the Tiny TinyMCE and the IMCE module to allow me to put images into the text and to give improved formatting options when entering text). I also made a few buttons to go on the site linking to my profile on various sites (Vencorps, Twitter, Facebook and LinkedIn) and then managed to create a new block containing my current Twitter Status (I used some code from the Twitter site but had to add a space in the empty ul and /ul tags).

As I said I added some links to the various sites mentioned above, playing with these sites has been part of where I’ve been wasting my time this week too. Vencorps is an offshoot of the old Cambrian House site that I was previously a member of. I completed my LinkedIn profile again just to pass some time, but I have one more thing I’ve been doing to waste time: GPS mapping.

I’ve been meaning to get a GPS receiver for a while so that I could participate in the OpenStreetMap project at: to create local entries for the map. My phone has a GPS receiver so by using the free (beer-yes, speech-?) I’ve been tracking my cycle routes and then tracing them using the JOSM mapping tool, which lets you plot roads and then upload them to the OSM server where on a Wednesday new details are added. If you look at the are around Halliwell and Astley Bridge you should see lots of details I’ve added. As other than one road there was virtually nothing drawn in between Chorley old Road, Blackburn Road and Moss Bank Way.

I don’t know if it’s my phone or if it’s the fact that I’m in a built-up environment but some of the traces I’ve done haven’t been particularly good. I reckon to do all of the bits in detail in this part of Bolton will take me a good few months. Before I start trying to add details on the map, I can check out what I’ve done using the SportsTracker website where I upload each route and it is displayed as an overlay on a GoogleMap, if it looks reasonably like the route I followed then the track has worked and is usable. If it is full of straight lines then I can’t really use it.

My profile at OpenStreetMap is:

Anyway, it’s time for bed.

Night, night.

Layouts in Qt

I think I’ve finally cracked the layout mechanism in Qt Designer, it isn’t straightforward and intuitive to get set up by any means. Basically once you have various bits you want to layout you need to start looking at their sizing policy, geometry and various other bits. You also seem to need to make liberal use of the stretcher things. You basically seem to need to nest the layouts one inside another if you you want buttons for instance in a column always a certain distance apart then you have to put fixed height spacers between each one, then select all of the buttons and spacers (not just clicking and dragging a box around them) then select layout vertically. If you then want them to remain reasonably constant in size as the width of the window decreases you need more horizontal spacers of a fixed width then a horizontal layout.

At this point you discover that you left the buttons horizontal size policy set to expanding which means they try to expand to take up all of the available room (if you put this current layout box in a horizontal layout with another expanding layout box they both expand to take up half of the width, the buttons stretching to fill the space). If you decide that you meant that the buttons should stay a reasonable size you need to go back and change their horizontal size policy, unfortunately this seems to involve breaking all of the nested layouts they were part of, changing the size policies an then re-instigating each layout box.

Maybe I’m doing it wrong but there must be a quicker way than this, should the layout boxes not inherit from the current settings rather than causing the affected items to behave unpredictably. Maybe this is a known issue but as I’m in Inverness in a holiday home I can’t check at the moment.

Listening: Manu Chao – Clandestino
Reading Book: Sergei Lukyanenko – The Night Watch
Reading Magazine: Linux Journal (Issue 172 – August 2008)
Drinking: Famous Grouse (in about 5 minutes time)

And so to bed.

CppUnit: Some More Discoveries

Tuesday 12th of August 2008 21:24

One thing I don’t think I mentioned in the last post is that in the ClassNameTest.cpp file we need to register the test suite using a macro:


which registers the test suite so that it will be run.

The assertions which are possible include (lifted directly from the api documentation at the CppUnit sourceforge page):

Aserts that condition is true.

CPPUNIT_ASSERT_MESSAGE(message, condition)
Asert condition is true, and display message on failure.

Fails with the message.

CPPUNIT_ASSERT_EQUAL(expected, actual)
Checks that both values are equal.

CPPUNIT_ASSERT_EQUAL_MESSAGE(message, expected, actual)
As above but fails with the message.

CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, delta)
Checks that expected is within delta of actual (delta should actually be epsilon!)

CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message, expected, actual, delta)
As above but fails with message.

CPPUNIT_ASSERT_THROW(expression, ExceptionType)
Asserts that the given expression throws an exception of the type given.

CPPUNIT_ASSERT_THROW_MESSAGE(message, expression, ExceptionType)
As above but with a message on failure.

This is the opposite of the above the expression does NOT throw an exception.

If it does throw an exception then we fail with the given message.

Assert that a CPPUNIT assertion will fail.

As above but with a message if the assertion passes.

Assert that a CPPUNIT assertion will pass.

As above but displays he message of it fails.

I think there are more possible assertions as the CppUnit Cookbook uses a statement in setting up the tests which checks for a given exception type being thrown.

Enough for today.

CppUnit Starting Out

I’ve decided to try and keep a bit of a blog by writing it in Emacs on my laptop and then copying the resulting text over to the actual online Blog.

This evening I’ve finished going through the first part of the CppUnit simple tutorial, but I still need to get a better idea of what is entailed in using it, so I’ll have to try working through the Cookbook even though it starts with other Test versions than the one in the Tutorial.

Maybe I should work through the cookbook and then write my own tutorial, using the development of my canvas class as a result then use the resulting tutorial as part of my write up for the final project. Plus I need to get CppUnit working on Windows so that I can do all of my testing there.

The basic tutorial covers setting up a Test Suite and demonstrates the use of CPPUNIT_TEST and CPPUNIT_TEST_EXCEPTION. But in the actual test section, it only uses CPPUNIT_ASSERT.

These seem to work as follows, we have files ClassName.h,
ClassName.cpp, ClassNameTest.h, ClassNameTest.cpp and ClassNameApp.cpp (plus I guess any user defined classes we need for the tests).

In the “Private” section of the class in the ClassNameTest.h file we put:

CPPUNIT_TEST( testFunctionName1 );
CPPUNIT_TEST( testFunctionName2 );
CPPUNIT_TEST_EXCEPTION( testFunctionName3, someException );

someException is an exception which inherits from runtime_error defined in . Then in the “Public” section of the class we declare:

void testFunctionname1();
void testFunctionname2();

We then go to the ClassNameTest.cpp file and define each of these two functions, eg:

void ClassNameTest::testFunctionName1()
Set up any variables
Do whatever needs doing
CPPUNIT_ASSERT( Some boolean test )

void ClassNameTest::testFunctionName2()
Set up any variables
Do whatever needs doing
CPPUNIT_ASSERT( Some boolean test )

void ClassNameTest::testFunctionNam31()
Set up any variables
Do whatever needs doing which should trigger the
exception defined above otherwise the test suite will fail due
to an expected exception not being thrown.

We either define the exception ourselves or use a runtime_error which is predefined.

Setting up the project requires a few steps.

Create a file containing:

dnl Process this file with autoconf to produce a configure script

and a containing:

# Rules for the test code (use ‘make check’ to execute)
TESTS = ExecutableName
ExecutableName_SOURCES = List of all of the source files to be compiled in
ExecutableName_LDFLAGS = $(CPPUNIT_LIBS) -ldl

We need a ClassNameApp.cpp file containing:


int main(int argc, char* argv[])
// Get the top level suite from the registry
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
CppUnit::TextUi::TestRunner runner;
runner.addTest( suite );

runner.setOutputter(new CppUnit::CompilerOutputter( &runner.result(), std::cerr) );
bool wasSuccessful =;

return wasSuccessful ? 0 : 1;

We need to do the following at the command line too:

$ touch Names of any source files we haven’t created yet.
$ aclocal -I /usr/local/share/aclocal
$ autoconf
$ automake -a
$ touch NEWS README AUTHORS ChangeLog (this stops automake complaining)
$ automake
$ ./configure
$ make check

make check builds and runs the test application for us, and this is what we have to run each time we wish to run the tests. Most of the above is based on the Simple Tutorial for CPPUNIT available at:


Bed now.