KIS Systems, Inc - Contract Programming for Unix/Windows/Web in C++/C#/PHP/Qt/.NET and other technologies.

KIS Technoblog

Technical ruminations from our chief codemeister – Rick Berger

Archive for the 'Programming' Category

Using QtCreator

Posted by rickb on 22nd April 2010

The Symbian development platform (on which I’m currently working) has historically been incredibly arcane. A modified C++ with a non-standard exception mechanism, for starters. And a whole bunch of pieces to install, one of which is a doctored up Eclipse IDE.

Qt doesn’t alleviate the proliferation of installation pieces, at the moment, primarily because everything is still in transition. In fact, you have to install a whole bunch more new pieces to get the development environment together on your desktop machine and on the phone.

QtCreator

One of those available new pieces is QtCreator, Qt’s answer to the IDE.

I’ve used a lot of IDE’s over my career, and they all have their pluses and minuses. MSDEV is great for MS-only applications (and is particularly brilliant in C#). XCode is cool on the Mac, and Eclipse is great for Java. I’ve been a fan of Eclipse since working with it on a Java project a couple of years ago, and so was looking forward to using it in the Symbian environment – since Carbide C++ (the blessed Symbian IDE) is based on it.

That proved to be somewhat less than productive – the environment is insanely fragile. I managed to break the debug perspective completely, just trying to move a few windows around (the Variables window, specifically). It took some research and digging down into the nest of hidden project files to find the proper configuration file to delete and get some order back to the IDE. Then, too, communicating with the phone required yet another panel with arcane settings, and that had to be reset, frequently.

Since I’m using Qt, I thought it would be an interesting exercise to use Qt’s blessed IDE, even thought it’s still at an early stage of development.

Order of Magnitude

I can honestly say, QtCreator has been a lifesaver for this project. For starters, though still in early incarnation, it’s really good and intuitive to use for Qt development. And, it seems to communicate with the phone more readily.

There are a lot of glitches, still – I have yet to get the on-device debugger to work. Judicious use of qDebug() statements have been the stop-gap measure around that – effectively reducing debugging to the proverbial ‘print statement’ technique. Not optimal, but it works. And I can’t get the debugger to work on the device in Carbide-C++, either, so it’s no effective difference, there.

Better than nothing.

But, what has been the real lifesaver has been the ability to take advantage of an outfall of what Qt ultimately is: a cross-platform development environment. What this means in practical terms is this: you can do a lot of development on the desktop!

When you install Qt, you can install two versions – one for the desktop, and one for the phone. QtCreator has a (admittedly wanky, but slated for improvement) configuration panel that allows you to switch between build configurations: desktop or device (actually, there are two configurations for the device, as well – emulator vs. actual device.) You have to flip a bunch of switches to do it, but I’ve gotten it down to a fairly manageable routine and can flip between the two environments with relative ease.

That ability has been nothing but a godsend (or maybe a troll-send) for this project of limited funding and limited timeframe. Turnaround (the time it takes to go through a code, run, debug, fix and do it again cycle) on the device is slow. Turnaround in the emulator is even slower. But turnaround on the desktop is fast – no loading required.

Because of that, I’ve been able to do a large bulk of the coding effort – getting the big stuff in place – on the desktop. It helps to create an appropriately sized main window, and you do have to have a jumparound here and there (primarily for the OpenGLES stuff and the menu system), but most of the code and components are exactly the same.

So, when it comes time to deploy to the device, most of the hard stuff has been done. Now you can focus on the harder, device-specific stuff.

Not the Same

Just to come full circle, QtCreator has some real promise. It has glitches – the VIM emulator is a great idea, but I’m seeing a bunch of issues with it. I’m told that much of this is fixed in the newer version.

It’s difficult to specify and organize source folders – I’ve taken to creating source file ‘hulls’ on the command-line in the directories I want them, and then update the .pro file, accordingly. The IDE will honor what you’ve created, and show appropriate folder organization.

Not on the Mac, though – the project contents are just a flat list of entries. You can still get to stuff, but you may have to scroll through a long list of other stuff to get to it. I imagine that will get fixed in the next update or two as well.

Summary

Overall, I think this will only get better. The Trolls (now part of Nokia) are working on this furiously (note the announcement of Meego and the parallel announcement that Qt will be the development platform of choice on that environment – it already is on Maemo).

For me, QtCreator will definitely become the development platform of choice for future Qt applications, with decreasing reliance on the platform-specific IDE.

Posted in Eclipse, Platforms, Programming, Qt, mobile | No Comments »

Qt on Symbian

Posted by rickb on 19th April 2010

Yet a new platform to exercise my Qt chops on.

As you may or may not know, Qt has been acquired by Nokia. It appears that Qt will be the development environment of choice for all of Nokia current and future OS’s, including Symbian, Maemo, and the newly announced Meego.

And that’s a good thing.

Leveraging Qt

I can speak for a newbie getting into the Symbian S60 environment: If it weren’t for Qt, this would have been a much more difficult endeavor.

As it was, I was able to put together a pretty sophisticated molecular modeling app, complete with 3D OpenGLES visualization, in about six weeks, thus far. (Still putting in HTML downloads and cleaning up interaction.)

It’s not without issues. The Trolls and Nokia are still getting to grok one another. So some things (like the menu system) display some strange behavior, and Qt doesn’t support OpenGLES on Symbian, yet (at least not on the S60 devices.) So, I’ve had to ‘go native’ for the OpenGL. Not the end of the world – it just means opening up a Native Symbian window and creating a QObject-based class to serve as a controller. It’s working fine.

Trying to do this in native Symbian would have likely at least doubled the development time, I think. By leveraging the Qt knowledge already gained, the process of moving to a new platform like Symbian is greatly facilitated.

Now, if we could just get Qt on the iPhone and Android (efforts are underway for these – see here and here.)

Posted in C++, Programming, Qt | No Comments »

QT Legacy

Posted by rickb on 8th January 2010

It’s occurred to me that, having worked in a number of languages and platforms, lately, just how much an influence Qt has been, particularly the signal-slot mechanism.

That single mechanism is, in my mind, as much an innovative development as the subroutine, the library, and the class.

Why so?

Fundamentally, because it provides a mechanism for incredibly strong isolation of modules, which, in turn, makes them more likely candidates for re-use. It also allows for stronger modular development in general – you can focus tightly on the functionality of the module and – perhaps even more importantl – you can hook tests to the module with ease. Unit testing is an easy and natural fallout of signals and slots.

IT’S WHAT I HAVE coined as ‘connection-based architecture’. (In ‘pattern-speak’, it’s called the observer pattern.)

Whatever you want to call it, it’s the best thing since sliced bread.

Once you’re exposed to it and have to go over to another language or toolkit, you immediately look for an equivalent mechanism in that technology. Some toolkits/languages provide the function inherently, others somewhat. For instance, Objective C implements it as part of the language construct. In fact, you could look at Objective C and wonder if Trolltech didn’t use it as a model – in effect turning C++ into an Objective C implementation. The syntax of Objective C for sending messages is a bit funky, but the functionality permeates every class declared in the language, which is better than Qt can do – you have to derive from QObject or embed a QObject-based instance to use it in C++.

The .NET CLR languages have a corollary in their delegate mechanism (not to be confused with Qt’s ‘delegate’ base class). Essentially, you can declare a delegate as a singular notification mechanism that behaves very much as a signaler, and you can register classes to receive it’s signals on a function. Syntax variants to declare and use delegates vary from language to language. In VB, it’s terrible (unless changed recently.) In C# (really the only language to write .NET apps in, IMHO), it’s easy.

As you go down the language line, it becomes increasingly difficult to use this kind of mechanism. ECMA-based scripting languages (ActionScript3, JavaScript), for instance, don’t have quite an equivalent mechanism, but the event mechanism is closely analogous. It’s reasonably easy to create a custom event and provide handlers for the event.

Server side languages are harder. Java actually has an Observer class, but it’s kind of clunky to use and not typesafe. Perhaps with the emergence of the generics construct, it may be easier to implement a signal-slot type of mechanism.

Of course, signals and slots are not the only thing that makes Qt a standout technology – the window and widget abstraction are often the rationale for using Qt in the first place. If you’ve ever tried to create a multi-platform application from scratch (I have – pre-Qt), it’s a lot of work and you’re often restricted to lowest-common-denominator functionality.

And, Qt provides some other niceties, as well – the bundled 3rd party functionality for things like XML handling relieves you from having to build and support these things as extras (which can be a difficult endeavor in a multiple-platform effort.)

But, the real conceptual leap (unless you’ve been a NEXT/Mac developer working in Objective C) is the signal-slot mechanism. The rest is UI abstraction, a certain amount of architectural framing (which is useful), and bundling.

That dynamic connection-based isolation capability is what I look for any time I have to make a move.

Posted in C++, Programming, Qt, Software Development | No Comments »

Once more, unto the breach…

Posted by rickb on 11th September 2009

… and with our coding dead… (with apologies to Shakespeare).

Again, I haven’t been keeping this up.. why? Spam is driving me crazy. I’m currently upgrading the server and will put in a captcha to re-implement comments. After all, what’s a blog without feedback?

Adobe Flex/Flash

On the development side, I haven’t been dormant: I’ve been investigating the new Flash and Flex technologies from Adobe.

Since Adobe took over Flash from Macromedia, there has been an all out push to turn the Flash technology into a bona-fide development environment. That makes it a candidate for investigation (especially to one who professes to be a graphics developer.)

The outcome? You can see one outcome on Facebook (this is also an exercise in exploring the ’social media’ platform): Active Biorhythm. It’s pretty cute – if you’re a Facebook user, you should be able to fire it right up (you might need to log in, first.) The first tab shows your six most compatible friends for varying attributes with a series of (active, of course) venn diagrams. The second tab shows your personal values with (active, again) bar-charts. (The ‘in-tip’ value labels is a nice touch…)

The third tab is the most interesting in terms of potential applications, IMHO: Think ‘Google Analytics’ type charting, with active information popups at appropriate places. As you hover over a curve, for instance, the other curves fade into the background and data at that point is reflected in an ‘info balloon’, which has a connector to the table readout value below, for good measure.

The current date can be changed by grabbing the red cursor and dragging it, or by hovering over the pointers on the sides of the graph. A friend can be loaded, either from the compatibility panel or from the name panel on top, and the chart will show comparison values, as well as a drop-down ‘compatibility panel’ for all attributes.

It’s an interesting demo of how to show a lot of information on a graph, without cluttering it up with legends, etc. I’m sure a graphics designer (which I don’t profess to be) could think of some very interesting possibilities. It needs a bit of work, still, but it’s quite functional.

The next exploration in this (Flash/Flex) technology will be a 3d library which has been built on top of Flash, talking directly to the GPU . From what I’ve seen, it looks very promising.

Aside: ActionScript3 is ok – it’s an ECMA-derived script, so there are a lot of familiarities. The only thing I don’t like is the kind of backward typing statements (typing, in and of itself is good, of course).

For instance, to declare a variable of type ‘String’ looks like thus:


var myVar:String;

Nothing wrong with that, but say this is local to a function and you want to promote it to class scope. What you need to do is remove the ‘var’ and the ‘:String’ so the lvalue in the assignment doesn’t have the type/instance declarations – that’s a two select-and-click process (other languages the type/instance declarations precede the variable name – one select-and-click to remove.)

No biggee, just a little bit of a nuisance.

Working with the FlexBuilder development environment is much better than working in the Flash Authoring Tool. The latter doesn’t help you very much — FlexBuilder is Eclipse, so it helps a lot (although not as much as it does with Java.) The only issue is that it produces large .SWF files, compared to those created with the FAT.

So, onward. I’ll be working the rest of the day putting in a ‘captcha’ and updating the wp software so comments can be left.

You will be free to add illuminating remarks when that’s done.

… but no spam!!…

Posted in Eclipse, Flash, Flex, Programming, Web Development | No Comments »

One Week to Write the Demo, Four to Document and Package

Posted by rickb on 7th March 2008

It is an axiom in software development – more often than not, it takes more time and effort to document a project than it does to actually do it.

Which is why a lot of documentation never gets written…

Qt Demo on the Loose

Which is why it’s taken forever to get my simple little Qt demo up and posted.

But, it’s there – QXListView is out for the world to see at http://qxlistview.sourceforge.net .

Video Throes

Part of the documentation effort has been making a video demonstration. My first attempt was to just use a video camera to shoot the screen – there’s no flicker issue with LCD’s, so it ought to work, right?

Well, it works, but the result was terribly fuzzy, so that wouldn’t do at all.

The next attempt was to find some screen capture software for the Mac. There are a few out there, but I settled on a beta thing called Screenium. I found a setting that gave me nice, clear video and proceeded to work through the demo.

Screenium is ok – has some nice feature, but it’s way beta. I had a lot of troubles with it stopping prematurely or just recording a blank screen (but with soundtrack.)

But, I managed to cobble together a bunch of clips. Next, I brought those up in iMovie, edited them, and prepared to export them, happily expecting a movie to come out the other end.

No such luck!! Sound, but no video.

Crawled around the web and after posting numerous questions in numerous forums, I discovered to my dismay that my ‘nice, clear video’ codec (’animation’, which is an Apple codec, I understand) was not exportable by iMovie (which is an Apple product, I understand.)

What to do? I didn’t want to pop for professional-level stuff just to do this little project, and I didn’t want to record everything over. So I started looking for converters and stumbled across MPEGStreamClip. This nice little app allowed me to convert the ‘animation’ coded clips to H.264 (with a myriad of settings I don’t quite understand), which is a variant iMovie could export. But, I lost my nice clear images in the bargain. Now they’re a little fuzzy, but they’re better than the video camera atttempt.

So, I could finally export my movie, package up the demo, and get it out to the site.

Next, I have to update my home site (this) to point to the demos.

A bit wanky, but hopefully once I work out the flow, more should be coming.

But, there’s something else coming up that’s going to impact the time I can put on this, and change the direction of the next few dozen blogs, I think.

More on that, later.

rickb

Posted in C++, Documentation, Programming, Qt, Video Presentation | No Comments »

Finding Unresolved Link References on the Mac/Gnu

Posted by rickb on 5th February 2008

I recently built a third party source on the Mac, only to find it had a number of unresolveds (link errors.)

If you build in XCode, the tool is kind enough to tell you what’s referencing the unresolved(s). From the commandline, it’s not so obvious.

Since this is third party code, I don’t want to have to go through the hassle of building an XCode project — but I need to find out which modules were referencing the link unresolveds.

Finally, after a bit of head-scratching, I got the solution — so I can share it, here, if you’re unlucky enough to be searching for this needed capability:

The Solution – Getting the Module/Filename That References the Unresolved

You need to enable a link flag ‘-y’, followed by the unresolved symbol (you’ll get that from the failed link output.) Go into the Makefile and find LDFLAGS (’ld’ is the gnu linker — this is the typical Makefile variable for the options) and add the ‘-y’ flag, followed by the symbol, like this:

LDFLAGS = -y__2435ZClass5FunctioniiiEi [rest of options]

Some of the symbols can get quite long — make sure you paste and copy the whole thing, including the leading underscores. Next time you do a build, the link step will output a line as to what module in your project references that symbol (yay.)

Your work’s not necessarily over — the lib I was building uses a very complex class hierarchy, and it wasn’t apparent which lines of code were causing the unresolved, even though I knew what file it was happening in. If that’s the case, then what I do is selectively #ifdef out parts of the file until I can make the unresolved symbol appear and disappear in subsequent links. Then I can narrow it down to the offending line and fix it. (You get a whole bunch of other unresolveds as you comment out sections of the code — ignore those, of course.)

Tedious, but it works.

I imagine the same would apply in a linux/bsd environment — anything that’s using the Gnu toolsuite.

rickb

Posted in C++, Mac, MacIntosh, Open Source, Programming, Software Development | No Comments »

Developing on the Mac

Posted by rickb on 22nd January 2008

Now that the Mac has finally settled down, I’ve been moving my development efforts off of Windows and onto the Mac.  And just recently, I’ve done a partial upgrade to Leopard (hedging my bets by installing it on an external USB drive.  Best of both worlds – I can boot Leopard off the USB, and Tiger off the internal.)

XCode is a reasonable IDE – better with the Leopard incarnation.  The integration with gdb is tight – I’m having to go to the cl gdb less frequently.  Qt is working just fine on the Mac, with no surprising ‘Mac’ gotchas.  (In fact, I’ve gotten more ‘gotchas’ in the linux environment than I have Mac.)(Or Windows.)

A few things I miss in the Windows environment:

  • Visual Studio has better capability to look at out-of-scope expressions.  If I want to examine the contents of a pointer, it’s easier in VS than in Xcode.
  • Visual Studio’s ability to debug Javascript in IE is simply awesome – it looks and behaves pretty much like any other language in the IE.
  • Windiff is still the best windowed comparison program in the land.

For PHP development, Zend’s Eclipse IDE port works fine on the Mac (and the latest incarnation adds a lot of features.)  For first cut debugging of Javascript, the Firefox debugger handles most cases – although in a crunch, I’m tempted to go back to MSVS for the more puzzling situations.

Still, for the most part, I’ve been ‘living in the environment’ and haven’t been tempted to shift back over to Windows for anything in particular.

So,  the Mac is becoming pretty much my mainstream preferred development environment.  With the addition of Parallels and a few scattered VM’s , I can do the verification builds and debugging on Windows and Linux as necessary, using net shares to access the central development environment.  There’s a bit of a time penalty for going this way – but I don’t build frequently in the VM’s and the trade-off for not having to carry more than one machine more than compensates for a slightly slower build.

Ah.  There is one area where the Mac is really hands-down the preferred platform: imaging.  For one thing, you can color profile both displays – an annoying shortcoming in Windows (XP, anyway).

Posted in C++, Mac, MacIntosh, Open Source, Parallels, Platforms, Programming, Qt, Software Development, Virtual Machine Software | No Comments »

Namespaces – A Good Thing

Posted by rickb on 30th November 2007

I’m becoming more of an advocate of namespaces.

Traditionally, they’ve been defined informally by prefixing function and/or variable names with some unique mnemonic – such as ‘Q’ for Qt stuff, ‘wx’ for wxWidgets stuff, or even something as potentially ambiguous as ‘C’ for MFC stuff.

All well and fine and helpful, but you can still run into name collisions. For instance, I was browsing the mac utility headers a while ago and ran into a raft of ‘QT’ names – for QuickTime. Dangerously close to ‘Qt’.

The newer languages, such as C# and Java, enforce namespaces. In C#, you can’t write a single line of code, unless it’s wrapped in a namespace.

The usefulness was heightened for me in a recent project with C#: we were attempting to use an underlying module for statistical binning and drawing. But, we needed a highly optimized version so we could dynamically select bins and draw the results on the fly.

Some customization was in order.

Now, in an ideal world, we would go to the creators, explain what we needed, and collaborate with them to get the enhancements we needed. In the real world, though, the creators are off doing something else highly urgent, and we’re not on their ‘to-do’ list.

So, we did the undesirable: clone the module and get the modifications in, ourselves.

Of course, we didn’t want our version to collide with the older version. How to avoid? Simple: since it’s C#, there’s guaranteed to be a namespace associated with the module. Just change the namespace of our cloned module and proceed.

Voila! (I’m writing this in Paris, so I get to stick in my bit of francaise.)

Of course, things aren’t quite so simple – the binning module used several namespaces (a bit of fragmentation overkill, IMHO), and relied on other underlying modules, which had to be detected and determined if they needed cloning, namespace changes, et al. It still can get pretty ugly. But the namespace feature helped.

Another time when namespaces would have been useful was when a somewhat recalcitrant vendor provided a package with a modified libjpg. Naturally, none of our stuff that relied on libjpg worked any more after we integrated their new code…

After the initial shock and dismay, we had to come up with a solution – the vendor was in Germany and were perfectly happy with the solution, as it was, so were disinclined to make changes. In that case, I think we isolated their libjpg into a fully resolved dynamic library along with their system, and didn’t export the jpeg functions. A pain in the ass, to be sure.

Back then, namespaces weren’t widely supported in the compilers (notably, Microsoft), but had they been, it could have been a better solution. Granted, libjpg is in C, but it can be compiled as C++ and then wrapped in a namespace that would prevent it from colliding with our libjpg (assuming we could get the vendor to cooperate.)

As software grows, and applications become more of a ‘mash-up’ of different modules, namespaces can become an increasingly important construct to eliminate conflicts. For instance, if Trolltech wrapped everything in a ‘TT’ namespace, or, better yet, a ‘TT_QT’ namespace, it would disambiguate them from any other code that might just happen to start with ‘Q’. Like ‘QT’ for QuickTime.

So, in my current effort (creating an extension for Qt), I’m wrapping everything in a namespace (’KIS_QX’). It means users will have to sprinkle ‘using’ statements in their code. A bit onerous, admittedly, but I think utimately that namespace usage is a good habit to get into.

Posted in .NET, C++, CSharp, Programming, Qt, Software Development, software, wxWidgets | No Comments »

Just When I Thought Things Were Fine…

Posted by rickb on 22nd October 2007

While constructing the previous post, I noticed a number of things I didn’t like, particularly in the list editing – the lists are cramped together, the lineheights aren’t right, and there’s no way to ‘paragraph off’ a list, like so:

  • This is a list item.
  • This is a continuing thought within the list item.
  • This is another list item.

Notice the break in the continuing item. That’s achieved with a special list item (using <br/> is crude – hard to style.)

If you specify a css rule for a continuing list item like so:

li.continue { list-style:none; margin-top:0.4em!important; }

you can define a ‘continuing list paragraph’. Problem is, when WordPress sees such a thing, it strips it out.

So, I’ve had to crawl through the code and figure out what the heck is going on. Way down deep inside, there’s a file that lists ‘allowedposttags’ – an array of arrays following canonical rules. A bit of a hack, and I’ve got <li> behaving the way I want.

Just have to save off the changes in case of upgrade.

Another thing I like is a stand-off paragraph – something to introduce a new thought in the text, without having to use something like a header. That’s how this paragraph is defined. Again, another class description:

p.class  { padding-top:2.0em; }

Or some such thing, and now I have a stand-off paragraph.

As usual, packages are great – they get things going. But, to get what you want, you have to dig inside of them and control them by the tail. WordPress is no different.

Posted in PHP, Programming, css, software, wordpress | No Comments »

Let Chaos Reign!!

Posted by rickb on 22nd October 2007

Ok, I’ve got about ten things going at once, here. I’m the incarnation of Andy Grove’s pre-commitment exploration dictum: Let Chaos Reign!! Of course, the other side of that dictum is that when you’re committed to a particular direction, you apply the inverse: Reign Chaos In!!.

Well, it keeps me from getting bored between gigs, anyway.

The top four things (as of the moment) are:

  1. Getting the Zend IDE up and running for PHP. Ostensibly, this would seem to be simple, but things are complicated by virtue of the fact that Zend has created a second IDE based on Eclipse. Eclipse is a good thing – it not only supports PHP, but HTML, CSS, XML, and the rest of the alphabet soup of net languages, for development on the net. But, it supports application development languages, as well, most notably C++ and Java.
  2. Assiduously avoiding Java (don’t like things that consume half the machine’s resources to run a ‘hello world’ program), but C++ is right in there.
  3. Ubuntu VM configuration. Ok, I like ubuntu bunches. I hate to say it’s almost ‘Windows-like’ in ease of use, but it is. It has what must be the best update manager in the open-source world – it really does ‘just work’.
  4. Qyoto investigations: C# and Qt – what I think may emerge as the best cross-platform agile development environment, ever. C# has all the advantages of Java, without the overhead penalties. Qt is the best cross-platform windowing environment, albeit the cost is almost usurious, at least for small developers. Maybe in the future there would be a wxSharp effort? Not sure how that would work with wxWidget’s message map architecture…
  5. I’ve put this up under monodevelop on the ubuntu system, but it’s not working (even though monodevelop says it is. Just copies down the reference .dll’s.Real anxious to get this working on as many platforms as I can.
  6. Getting the WordPress rss feed plugin working. That’s the last piece of this blog. It’s installed, it’s recognized, I can set things up, but it doesn’t output anything.
  7. Getting that done will finish up the blogging system.

It sounds like a lot, and it is, but it interleaves – a lot of these are embryonic efforts (especially Qyoto) and they require some feedback from forum query’s before I can continue. So, I can drop one while waiting for a response and pick up another. Or pick up the other when I get a neuron spark.

Posted in C++, CSharp, Linux, Mac, PHP, Platforms, Programming, Qt, Virtual Machine Software, software | No Comments »