Slashdot Mirror


C++ GUI Programming with Qt 4

Ravi writes "When somebody talks about the Qt Framework, the first thing that comes to mind is KDE one of the most popular Desktops which is built using the Qt library. Qt is a C++ GUI framework created by the Norwegian firm Trolltech which can be used to build applications for a variety of OSes and platforms. The latest version of Qt (Ver 4.0) contains huge improvements over its earlier versions such as advanced modal/view functionality, easy to use template containers and better Unicode support just to name a few. I have been excited about the ease with which one can build GUI applications using Qt. Trolltech provides the library in two licences - the free licence which mandates that the applications developed be released under GPL and a commercial non-free licence which allows one to develop closed source applications using Qt." Read the rest of Ravi's review. C++ GUI Programming with Qt 4 author Jasmin Blanchette and Mark Summerfield pages 540 publisher Prentice Hall rating 9 reviewer Ravi ISBN 0-13-187249-4 summary A great book to learn the latest version of Qt (Ver 4.0) to create applications that run natively in Linux/Unix, Windows and Mac OS X

I found the latest book on Qt titled "C++ GUI Programming with Qt 4" authored by Jasmin Blanchette and Mark Summerfield and brought out by Prentice Hall to be a remarkable book in that it takes the readers through the basics of creating applications using the latest version of Qt and gradually shifts to explain the more advanced concepts of GUI programming using this C++ framework.

The book, all of 540 pages is divided into three parts - the first part containing 5 chapters dealing with Basic Qt, the second part titled Intermediate Qt which contains 11 chapters and the final part titled Advanced Qt containing an additional 5 chapters.

The major work in picking up skills in a new GUI framework revolves around getting to know all the classes and their member functions. And learning Qt is no different. In the first five chapters (Part I of the book), one gets to know the rudimentary concepts behind creating GUI applications using the Qt toolkit. And remarkably, instead of boring the readers with the different Qt classes, the authors take a hands on approach and introduce the concepts via examples.

In chapters 1 through 5, the readers are introduced to rapid dialog design using the Qt Designer, introduction to the main Qt classes such as QApplication, QObject, QWidget and its child classes as well as a good understanding of the concept of Signals and Slots which form the meat behind communication between different objects in Qt. Apart from that the 5th chapter also introduces to the reader the concept of Double buffering - one which is used popularly by the programmers in eliminating flicker in the GUI interface.

The sixth chapter titled "Layout Management" falls in the second part namely "Intermediate Qt". Here one gets to know and tryout the different layout classes that are available in Qt using which one can easily design sophisticated GUI applications. This chapter also gives the reader an introduction to Multiple Document Interface by way of an example.

Event Processing forms the basis of the seventh chapter where the authors explain how to catch events such as key presses and timers. Apart from that the authors also explain the five levels at which events can be processed and filtered in Qt.

Qt has an excellent collection of classes for creating 2D and 3D graphics. And from version 4, the classes are grouped into modules which need only be plugged in on a need to use basis. The primary class which deals with the 2D graphics engine in Qt is the QPainter class. The use of this class has been explained in detail in the eighth chapter titled "2D and 3D Graphics". Other than that, one also gets to know about the OpenGL module in Qt which makes it very easy to integrate OpenGL code into Qt applications as well as the classes which implement printing.

It is really interesting to see that the entire subject of Qt is apportioned into separate chapters with each chapter dealing with a particular topic. For example, if in the 9th chapter, the authors dwell on explaining the classes which implement drag and drop support, the succeeding chapter elaborates on the Model view controller architecture which forms the basis for most item view classes which implement tables, tree views and lists.

Another thing worth noting is that each chapter is explained with a complete stand alone example which makes it easy to try out what one has learned and also get a better idea of the concepts behind the classes that are explained. So while learning say about the container classes in Qt, the reader can actually try out an example and the code is accompanied by step-by-step explanations which makes it much more simpler to grasp the concepts.

All object oriented languages contain what are known as container classes - those which are responsible for creating sorted and unsorted data arrays, vectors and lists. And C++ has a couple of them in the Standard Template Library (STL). Qt has its own wide array of container classes which sport a number of improvements over STL in that they support implicit sharing (Copy on Write) which gives the applications a significant performance boost. In the 11th chapter titled Container Classes, the authors explain the concept of containers and the Qt classes that can be used for the same.

The next two chapters deal with writing and reading data from files as well as databases. And in each case, the concepts are explained with the aid of examples which makes the narration much more interesting to follow.

Qt has good support for Networking as well as XML which is evident from the 14th and 15th chapters which elaborate on the classes responsible for these. Even though these two short chapters do not cover all the networking or XMl concepts, I found them to impart a good idea of the use of a couple of important Qt classes related to networking and XML.

The 17th chapter titled "Internationalization" falls in the Advanced section of the book. I found this chapter to be an eye opener in that, with Qt's robust use of Unicode, it is possible to create applications which support a wide variety of non-english languages.

But one of the very important concept of multi-threading is explained in the next chapter titled what else "Multithreading" where the authors teach how to create threads easily in Qt.

If one looks at any KDE application, it will be evident how the parent application can be extended by use of plugins. A plugin is a dynamic library which implements a particular interface to provide extra functionality to the user. In the 19th chapter, one gets to know how to create dynamic libraries using Qt which can then be plugged into the parent application.

In the penultimate chapter, the authors explain all the platform specific features and tweaks such as using ActiveX in Windows and handling session management in X11. There are also four pages - which I believe to contain the shortest chapter I have ever come across and where a couple of classes which can be used in programming for embedded devices such as mobile phones are listed. By including this tiny chapter, perhaps, the authors were sending a signal to the developer community that Qt is fully ready for use in embedded development.

From start to finish, I found the book immensely enjoyable. The style of narration of the authors which interleaves the example code with the explanation is ideally suited to pick up skills in using any toolkit without getting bored, especially since the bulk of the learning involves acquiring a fine understanding of the classes the toolkit provides. As a bonus the book also provides an appendix which gives an introduction to C++ for programmers who use Java or C#.

The single CD accompanying the book contains Qt library in the source form for the Linux platform as well as for Windows and Mac platforms. I did not have any problems in compiling the source and installing the library in Linux using the instructions provided in the book. And within a little more than an hour (the time taken to compile the source code), I was able to start coding and compiling the examples given in the book. All in all, I find this book to be an invaluable guide in picking up skills in programming in the latest version of Qt (4.0).

Ravi Kumar likes to share his experiences in programming and in using Linux through his blog on Linux."

You can purchase C++ GUI Programming with Qt 4 from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

148 comments

  1. I am the very modal of a modern slashdot editor by edittard · · Score: 2, Funny
    advanced modal/view functionality
    That's a combination of model/view and modal dialog boxes, is it?
    --
    At the bottom of the /. main page it says 'Yesterday's News'. Well they got that right.
    1. Re:I am the very modal of a modern slashdot editor by benplaut · · Score: 1

      Not sure if everyone caught the reference to Pirates of Penzance... http://en.wikipedia.org/wiki/Major_General's_Song

  2. Update on the link by Anonymous Coward · · Score: 1, Informative

    Slashdot has linked to B & N here, but it seems that Amazon has it much cheaper.

    1. Re:Update on the link by Anonymous Coward · · Score: 0

      But Amazon are more evil. (One-click patent, promising they were going to fight patent craziness then not doing so, etc.)

    2. Re:Update on the link by rm999 · · Score: 2, Informative

      And your link doesn't have a referral tag (which I hate because I know those are the next popup windows of the internet).

      It's hard to write a bad review when you know you will make money if people buy it...

    3. Re:Update on the link by ryturner · · Score: 1

      If the choice is paying less at an "evil" store or paying more at a "good" store, then that is an easy choice for me. I am going to purchase from the "evil" store. This might not be the most popular choice on slashdot, but it definitely explains why Walmart is so successful.

    4. Re:Update on the link by Anonymous Coward · · Score: 0

      Pffft. I'd be willing to pay more at the evil store.

      Being bad is more fun than being good.

    5. Re:Update on the link by eviltypeguy · · Score: 1

      Bookpool has it even cheaper ($32.95 USD).

  3. Interoperability by lkeagle · · Score: 2, Insightful

    Does the book explain any methods for dealing with interoperation with other frameworks? Gnome, perhaps?

    I've always found that the most useful books are the ones that provide direction on how to get your application to work well with others...

    P.S. F.P.

  4. 4.1 is the latest version by fornwall · · Score: 0

    Not 4.0.

    1. Re:4.1 is the latest version by stupidfoo · · Score: 1

      Wrong. 4.1.4

    2. Re:4.1 is the latest version by Anonymous Coward · · Score: 0

      4.0 attow

    3. Re:4.1 is the latest version by fornwall · · Score: 0

      Actually, 4.1.4 is a point release of 4.1, so both "4.1 is the latest release" and "4.1.4 is the latest release" are correct statements.

  5. Platform license. by Anonymous Coward · · Score: 1

    "Trolltech provides the library in two licences - the free licence which mandates that the applications developed be released under GPL and a commercial non-free licence which allows one to develop closed source applications using Qt.""

    Does the latter apply to Windows?

    1. Re:Platform license. by ardor · · Score: 4, Informative

      Sort of. The Windows version has the same license, but has no VisualC support - this is included in the commercial version only. The free one only supports MinGW.

      --
      This sig does not contain any SCO code.
    2. Re:Platform license. by Anonymous Coward · · Score: 0

      > Trolltech provides the library in two licences -
      > the free licence which mandates that the applications developed be released under GPL

      Sorry but this is misinformation! The free license doesn't mandate applications released under the GPL but under an OPENSOURCE license.
      This has been assured until Qt 4.1 by providing the library under two opensource licenses: QPL AND GPL.

      > and a commercial non-free licence which allows one to develop closed source applications using Qt."

      Since Qt 4 the 2 free licenses as well as the commercial license apply to X11 as well as native Windows.

    3. Re:Platform license. by Anonymous Coward · · Score: 0

      Nothing in the GPL limits what platforms you can run GPL code on. Ever since Qt was released under the GPL for unix-like systems, it would have been entirely legal to port to Windows. However, Windows programmers don't get the whole Open Source thing. The only programs anyone ever writes for Windows are viruses, worms, adware and spyware. There has never, ever been a single documented case of an Open Source program starting out on the Windows platform and then moving to Linux / BSD. This is because Windows programmers are motivated solely by the idea of selling programs for money; and as long as the EULA can make it a more serious offence to attempt to examine a program than to go out on a crack binge and rob, rape and murder four generations of a family, nobody will ever see how badly their programs were written.

  6. Update for 4.2? by Abby+The+Wonder+Dog · · Score: 2, Informative

    It is too bad that this book couldn't have been based on version 4.2 coming out soon. There are some major new features in the upcoming release, most importantly (IMHO), QGraphicsView, the new canvas. http://doc.trolltech.com/4.2/qt4-2-intro.html

    It also looks like they'll try to squeeze in some cool SVG related stuff. http://zrusin.blogspot.com/

    Man, Qt simply pwns GTK

    1. Re:Update for 4.2? by Almahtar · · Score: 1

      I was never a KDE fan - I always liked Gnome stuff better, until I programmed in Qt for a project at school. After working with Qt I got absolutely sold on it and KDE. I kind of wish that GTK was better than Qt because then I would use it on commercial products, but honestly I'd gladly pay the fee to use Qt.

    2. Re:Update for 4.2? by Anonymous Coward · · Score: 1, Informative

      "Man, Qt simply pwns GTK"

      Yes, I agree, except for one thing. GTK has the nice feature of being able to switch input methods easily without having to install additional keyboard layouts or whatever. As someone who uses the transliterated Cyrillic input method frequently, I wish QT/KDE would add this.

    3. Re:Update for 4.2? by Anonymous Coward · · Score: 0

      Try to get themed icons in Qt. Or, for that matter, try to install any theme that doesn't come packaged with Qt (hint: you can't). You also can't set an SVG as an icon, or create resizable dialog windows.

      Qt is easier to code with, but GTK+ is far more powerful.

    4. Re:Update for 4.2? by bhalo05 · · Score: 1

      I haven't looked into Qt themes, but regarding SVG...

      >> The addition of a Scalable Vector Graphics (SVG) icon engine enables icons to be created from pictures in this vector graphics format.

      http://doc.trolltech.com/4.2/qt4-2-intro.html

      And of course, resizable dialog windows are possible in Qt since the dawn of time. Not only that, they work wonderfully. Trolltech has done quite a good job with its layout managers.

      The truth is Qt 4 and specially Qt 4.2 are far, far ahead of GTK, like it or not.

    5. Re:Update for 4.2? by Anonymous Coward · · Score: 0
      And of course, resizable dialog windows are possible in Qt since the dawn of time. Not only that, they work wonderfully.


      They do not work. A QDialog does not contain a central widget. You can't create a QDialog that will resize its contents - you must either code up your entire dialog from scratch using a window, or block the user from resizing the dialog so they don't realize what's really going on. Dialogs in general are handled badly in Qt - there ought to be a QWindow class, which has subclasses QMainWindow and QDialog.

      By the way, you didn't respond to my theme statements. Gtk+ comes with a large variety of stock images, which can be overridden by user themes at will. Almost every part of GTK+, from the colors to widget shapes, can be changed in user themes. Qt has no way to do either of these without linking in bloated external libraries.

      Until Qt 4, there was no way to load .ui files at run time. This is a huge pain for those of us who must spend time in Qt 3 land, which is still the vast majority of the install base.

      Qt still has no support for "recent documents", requiring the user to keep track of and build this list himself.

      Qt has many good points. It's much easier to subclass a Qt class than a GTK+ class. There are no ugly GTK_HUGE_CLASS_NAME casts required in the code. But GTK+ has been, and remains, more capable than Qt for projects that need it.
    6. Re:Update for 4.2? by Mitchell+Mebane · · Score: 1

      "They do not work. A QDialog does not contain a central widget. You can't create a QDialog that will resize its contents" You don't need a central widget. You just have to set a layout on the dialog. Actually, you have to do the same thing for a QMainWindow, too.

      --

      The roots of education are bitter, but the fruit is sweet.
      --Aristotle
    7. Re:Update for 4.2? by wysiwia · · Score: 1

      I was never a KDE fan - I always liked Gnome stuff better, until I programmed in Qt ...

      If you don't like coding with GTK for Gnome, why didn't you try wxWidgets?

      O. Wyss

      --
      See http://wyoguide.sf.net/papers/Cross-platform.html
    8. Re:Update for 4.2? by Grab · · Score: 1

      If you're only on Linux, then fine. If you need cross-platform support, KDE isn't an option, in spite of it being on top of Qt.

      I still can't understand why a group of apparently intelligent people decided to take Qt, which provides a cross-platform widget set and significant parts of an OS abstraction layer, and use it to build a single-platform setup. If they just wanted a single-platform widget set for Linux, what was wrong with Lesstif or some other free widget set? But taking something built for cross-platform and nailing its feet to the floor - that takes a special kind of blindness.

      Grab.

    9. Re:Update for 4.2? by Almahtar · · Score: 1

      I've tried wx, actually. I use it at my current job. After having been spoied with Qt, I'm not such a fan of wx. To be completely fair I haven't tried a whole lot of GTK programming, but I haven't been impressed with the Windows GTK ports I've seen.

    10. Re:Update for 4.2? by Almahtar · · Score: 1

      Well the desktop environment itsself may not be intended to ever be ported away from *nix, the apps made for it can still be ported, right? I for one would love to see Amarok on Windows. Apps written for KDE that are ported over to Windows could be some great advertising for *nix and KDE. People seem to be under the impression that there are no good apps out there for linux, but that's likely because they've never tried them (and never will unless they can try them in Windows first).

      The KDE guys also could've chosen Qt for the features it provides aside from the cross-platform support. Its Signal/Slot system is powerful, its API is very powerful, it's efficient, it's very well documented (and always has been) the list goes on.

      Anyway, I'd go for a KDE Windows port instantly if there was one. Hell, I usually use KDE under colinux at work (hey! don't laugh at me!). If I have to use Windows it might as well feel like home.

    11. Re:Update for 4.2? by wysiwia · · Score: 1

      ... but I haven't been impressed with the Windows GTK ports I've seen.

      Neither have I but there's where wxWidgets shines. It might not look perfect on each platform but on any I've seen it looks acceptable. wxWidgets uses native win32 on Windows, Carbon/Cocoa on the Mac and GTK/X11/Lesstif on Linux/Unix. QT might be better but there's no OpenSource outside KDE. IMO there's no reasonable alternative to cross-platform development.

      O. Wyss

      --
      See http://wyoguide.sf.net/papers/Cross-platform.html
  7. mysql-style licensing by kpharmer · · Score: 0

    > Trolltech provides the library in two licences - the free licence which mandates that the applications developed be
    > released under GPL and a commercial non-free licence which allows one to develop closed source applications using Qt.

    So, I wonder if like MySQL people will always assume that it is free?

    1. Re:mysql-style licensing by Anonymous Coward · · Score: 0

      So, I wonder if like MySQL people will always assume that it is free?

      That's why I don't use MySQL. I use PostgreSQL. Plus you get all of the features free and for free. Heck, you can use MS SQL Express edition, Oracle Express edition or DB2 (IBM) Express edition for free as well. Only MySQL cannot be used for free in commercial projects. But it is not a big deal thanks to PostgreSQL

  8. Re:gui and native code - bad combination by gatkinso · · Score: 2, Informative

    Well, when I write C++ code, I rarely use malloc().

    --
    I am very small, utmostly microscopic.
  9. gui and native code - Mind Bender. by Anonymous Coward · · Score: 0, Funny

    "I've coded a lot of GUI code, in everything. Pascal, C, C++, Java, Tcl/Tk, Perl/Tk, HTML, you name it."

    Brainfuck?

    1. Re:gui and native code - Mind Bender. by YetAnotherLogin · · Score: 1
      "I've coded a lot of GUI code, in everything. Pascal, C, C++, Java, Tcl/Tk, Perl/Tk, HTML, you name it."
      Brainfuck?
      Whitespace?
  10. writing this from KDE4-WIN32 by Anonymous Coward · · Score: 0

    I am writing this comment, using Qt4/KDE4 compiled natively for Windows.

    With this build, you can use the KDE Desktop as the Windows Desktop.
    The kconsoles have real scrollbars, history and resize.
    You can't really tell that it is not Linux.

    Oh wait..., I am using Linux.
    Sorry. Let me reboot and see if I can run the unreleased windows build.

    -ac

  11. Re:gui and native code - bad combination by hubie · · Score: 1

    I know everyone has their favorites, but I'm curious that if you were given complete control over developing a basic multi-OS application (for arugments sake, something real simple with all the usual expected GUI boxes and features), what language combo would you use?

  12. Re:Norway by Anonymous Coward · · Score: 0, Funny

    Yes, as the current King of Norway, I can confirm this.

  13. The free edition by ratta · · Score: 2, Insightful

    does not require the application to be GPL, it requires it be open source (OSI), since the free edition is dually licensed GPL/QPL. The funny thing is that if Qt were QPL only, you could use almost all opensource licenses (eg. BSD) but not GPL, because the GPL require anythings you link with to be GPL compatible as well! So dual licensing is really necessary :)

    --
    Wondering why i am doing so strange posts? I am trying to get a "+5,Flamebait" or "-1,Insightful" rating.
    1. Re:The free edition by Almahtar · · Score: 1

      I thought your project had to be licensed under something GPL compatible. OpenSource.com has a few lists of GPL compatible licenses, btw. So that rules out BSD licensed projects using Qt, as far as I knew.

    2. Re:The free edition by fmoliveira · · Score: 1

      Its not proven in court that you cant dynamic link to anything. And copyright laws are not the same in every country anyway. Anyone big enough for trolltech to notice they exist and sue them would have no problem buying the license anyway.

      The real problem is that, imagine trolltech stop licensing it, or if the distros just fork it. It would be rendered useless for commercial applications. If it were not for gnome it could be a major drawback for linux.

    3. Re:The free edition by BlueLightning · · Score: 1

      imagine trolltech stop licensing it

      http://www.trolltech.com/developer/knowledgebase/1 89/

      or if the distros just fork it

      "The distros" could just as easily fork Gtk. Why is this issue specific to Qt?

    4. Re:The free edition by fmoliveira · · Score: 1

      GTK free license allows comercial software to link to it. Thats not true for QT.

      The dual-licensing used in QT depends on Trolltech being the owner of all of it. Any small change in the gpl version that is not owned by Trolltech will not be able to be licensed for comercial purposes.

    5. Re:The free edition by fmoliveira · · Score: 1

      Now, following the link of the grandparent, I read that there is an agreement that if they cannot continue the KDE Free Qt Foundation is allowed to release a bsd style license for it.

      http://www.kde.org/whatiskde/kdefreeqtfoundation .php

      This foundation is allowed to do that, but they could disappear before Trolltech. Forever is a long time, and I like to think linux will live forever.

      This is probably the biggest advantage linux has over any comercial OS. Microsoft can go bankrupt, but there is no way to kill linux. (nor BSD too)

    6. Re:The free edition by aichpvee · · Score: 1

      "If it were not for gnome it could be a major drawback for linux."

      What are you getting at? gnome is already the biggest drawback of Linux for me, and I never even have it on my machines.

      --
      The Farewell Tour II
    7. Re:The free edition by BlueLightning · · Score: 1

      GTK free license allows comercial software to link to it. Thats not true for QT.

      That's true, however the licensing of Qt is about as flexible as it can be whilst still allowing Trolltech to continue doing business. It's pretty reasonable if you ask me.

      Any small change in the gpl version that is not owned by Trolltech will not be able to be licensed for comercial purposes.

      Nobody is going to fork the Qt GPL version unless Trolltech start taking it in the wrong direction. Given the nature of Trolltech as a company, the people behind it, and their track record, that is unlikely.

      I don't buy into the suggestion that allowing commercial developers to basically freeload without contributing back is a good thing. Qt is a quality toolkit which saves development time, so IMO it's not too much to ask commercial developers to either release the source code or pay for a commercial license.

    8. Re:The free edition by fmoliveira · · Score: 1
      I don't buy into the suggestion that allowing commercial developers to basically freeload without contributing back is a good thing. Qt is a quality toolkit which saves development time, so IMO it's not too much to ask commercial developers to either release the source code or pay for a commercial license.

      Pay attention to this contradiction. Trolltech claims they cannot mantain themselves without selling a commercial version of their license. Someone that is just starting to work as a freelancer in the 3rd world would never be able to afford for QT, so I think its important to have free as in beer developing tools that allow it, like gtk or java. It doesnot mean that this guy will never contribute with anything.

      I dont see much sense in releasing free software and then complain that people are freeloading it.

    9. Re:The free edition by Anonymous Coward · · Score: 0

      If you are selling a product, making profit from it, you can afford the commercial license. If you cant afford it, release it under the GPL and charge for support. What is wrong with this?

    10. Re:The free edition by BlueLightning · · Score: 1

      Someone that is just starting to work as a freelancer in the 3rd world would never be able to afford for QT

      Well, in this situation there is another option provided by TrollTech:
      http://www.trolltech.com/trolltech/products/qt/lic enses/licensing/smallbusiness

      I dont see much sense in releasing free software and then complain that people are freeloading it.

      This "freeloading" I speak of is against the spirit of the GPL, which is designed to encourage community contribution.

    11. Re:The free edition by fmoliveira · · Score: 1

      Its not so hard to imagine an average joe, that bought his computer in 24 monthly payments, making a 20 dollars program and selling it around, that wont make enough money to pay for that license while he is still eating.

      In real life, this joe usually has pirated software, or he would use the free version of something and ignore the rules or something. But I think its a case where GTK licensing fits better.

      This discussion is getting pointless, as we have both them. We dont have to choose one.

  14. Re:gui and native code - bad combination by ardor · · Score: 2, Insightful

    Indeed, GUI development is one of the areas where managed environments shine. However, it IS possible to deal with this in C++. I agree that if I want to put a label in a window, I dont want to have to handle its deallocation, i.e. I want a "fire-and-forget" feature. I accomplished this in my wrapper by letting the parent deal with its children. It is a very simple concept, but works very well. I can write "new Label(mainwindow,"Here is my label",22,11);" and do not ever have to worry about a delete call or about memory leaks.

    IMO the best thing is to make the GUI purely data-driven, however. Stuff the entire layout in a XML, and the application only has to connect its event handlers to the named signals (assuming a signals-based event dispatching mechanism). AFAIK libglade does it like this. The huge advantage is that redesigning the interface no longer requires code modification. Don't like the button position? Move it down, you dont even have to recompile.

    --
    This sig does not contain any SCO code.
  15. Qt is very nice. by soft_guy · · Score: 1

    Aside from also being a very good cross platform library, Qt is also just a very nice programming API period. If you are just writing Windows applications, Qt is a pretty good choice. I highly recommend it. In fact, you are soaking in it now!

    --
    Avoid Missing Ball for High Score
    1. Re:Qt is very nice. by Almahtar · · Score: 2, Informative

      In my senior design class my last year of college, the project was to build a Windows app that did X, Y, and Z - any extra features and polish were left to the students' imaginations. The 3 students that used Qt did substantially better than the others, and their stuff ran on Windows, Mac, and Linux. None of them reported having to change a single line of source code porting from one platform to the next. The 6 Java people didn't do as well as the .net people overall, but their stuff ran on Mac most of the time. They reported spending some time and effort to get the Mac version working. The 8 .NET people by and large got better ratings than the Java people as far as features, usability, and speed, but their stuff only ran on Windows. So while the populations weren't large enough for anything vastly conclusive, it is a tribute to Qt that the 3 students using it did noticeably better than the 14 others just on windows, but also ran on Mac and Linux.

    2. Re:Qt is very nice. by ragefan · · Score: 1
      The 6 Java people didn't do as well as the .net people overall, but their stuff ran on Mac most of the time. They reported spending some time and effort to get the Mac version working.

      I call "Shenanigans" on this. I'm not a Java fanboy by any means but I would have to say that if they could not get it to run on Windows, Mac and Linux, then clearly they were not very good coders. The projects I did in Java for my programming classes ran on Windows and Linux with never a problem. My machines were Linux at home and Windows (sometimes dual-boot) at school and I constantly transported the project files back and forth and not once had an issue of running on one platform but not the other.
    3. Re:Qt is very nice. by thegrassyknowl · · Score: 1

      As someone who's used QT in it's non-free form, I can say that it is the bane of my existance. Trolltech do not provide licenses for a company. They provide developer-locked licenses.

      If someone without a Qt license identifies a change in my code and I am off on a week of leave they are not legally allowed to make the change. Sure, they could log in as me, enter source control as me and do the work. But there is no way in hell I'm giving them my password so that screws all that up.

      It also makes it hard as other users come along and want to develop plugin components for the application I am developing because they either need a license to Qt or they have to come to me every time they want to build.

      The other things that bothers me is they sell different types of licenses - console and gui. With a mix and match of these licenses in the company it's a pain in the ass when someone with only the console license runs our build scripts (which build about a dozen gui/non-gui applications) and comes back to me when it fails and says "you are not licensed to use the GUI version of QT".

      The framework itself is pretty good; I don't like the way it works, personally; I grew up on a wxWidgets style of programming which is somewhat different.

      On that note, stick to wxWidgets. It's LGPL-derived license allows commercial or opensource development, and it's just as powerful.

      --
      I drink to make other people interesting!
    4. Re:Qt is very nice. by Almahtar · · Score: 1

      I kid you not. First off, they had problems right off the bat loading large image files. There's some limit to the size of a jpg you can load in Java's standard libraries (at least with default settings), so most of them couldn't load say a 5000x5000 image. Not sure if any of them ever found a workaround for it. I watched 3 other students' final presentations: 2 used Java and 1 used VB.NET. One java guy chose java because he wanted to develop on his Mac and only use Windows machines for testing. He wasn't clear (wish I could give you details, but I don't know them) about what issues he ran into but during the last month or so of the project he ended up just staying on Windows machines because something broke badly enough (portability-wise) that it wasn't worth his time to figure it out. His version did not work on Mac anymore at the time of the presentation. He reported testing it in Linux using both the Sun VM and the free-as-in-speech VM and neither worked out for him. The other java guy didn't report the status of his program on any platform except Windows, so for all I know it could've worked flawlessly or it might just eat shit if you ran it on a Mac. No word on Linux either. Oh, and there were some pretty serious speed issues on his app, but he did implement some pretty fancy features... So yeah, sorry I don't have details about what exactly didn't work, but shenanigans it aint.

  16. Other Book by MrCopilot · · Score: 1
    May I be the first to reccommend http://cartan.cas.suffolk.edu/moin/OopDocbookWiki

    Fine teaching text, so far.

    --
    OSGGFG - Open Source Gamers Guide to Free Games
  17. How to get Qt to work with Visual C++ by everphilski · · Score: 2, Informative

    It is possible ... and not too difficult instructions here

  18. Re:subject by Anonymous Coward · · Score: 0

    Besides the fact that some of the things you have cited have been heavily focused on in qt development, it remains a developers tool; a toolkit if you would. Qt is not aimed at users, just like WinForms isn't.

  19. Design flaws in QT? by Anonymous Coward · · Score: 4, Insightful
    Has anyone using the QT API noticed that its behavior when it encounters an error isn't well-defined or easily detectable by the user of the library? For instance, look at QFileInfo's size member function.

    Returns the file size in bytes, or 0 if the file does not exist or if the size is 0 or if the size cannot be fetched.


    So, if it returns a zero, that could mean that there is a problem that your application may need to do something about or report, or the file does not exist, or the file exists but is zero bytes. How incredibly uninformative. But at least that member function documents its behavior it something bad happens. As I glanced through the other member functions, it became apparent that most of them do not bother to say what happens when the shit hits the fan. No return codes, no exceptions, no nothing.

    Sadly, many of the classes in the library are like this. Sure, I could write an application using QT, but I wouldn't know how to handle failures simply because QT doesn't document the behavior in those cases. This is surprising, considering that QT is considered a quality library that is worthy of use in commercial applications. Granted, most of the time, we'll only execute the "happy path", and there will be no problems with this lack of documentation. However, we shouldn't throw caution to the wind and assume everything will be OK.

    I can't help but think that this could have been avoided if QT would have embraced exceptions. Then, the API could avoid using C-like return codes and maintain its elegance but still report errors in a manner that is convenient for handling and documentation. QFileInfo::size() could be documented to throw QFileNotFoundException and QIOException, for example, making it easy for the user of the class to tell what happened. But they would have to rethink some of their code if they did this, because the naked-pointer-filled code that they have now would not be exception safe at all. I doubt that they will make the switch any time soon because everyone seems to be so happy with it the way it is today.
    1. Re:Design flaws in QT? by Jerry · · Score: 2, Insightful

      I've seen you post this question on QtCentre, too.

      Use QFileInfo::isFile to determine if the file exists, then QFileInfo::size returns the file size in bytes, or 0 or if the size is 0 or if the size cannot be fetched.

      What's so hard about that? You've never run into tri-states before?

      --

      Running with Linux for over 20 years!

    2. Re:Design flaws in QT? by AuMatar · · Score: 2, Insightful

      Returning a negative number for failure would have been better- you don't have to worry wether 0 means an empty file or an error, it would always mean an empty file, and < 0 would always mean an error. You could also then return different negative numbers for different error conditions. It may have a work around, but its a poor design.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    3. Re:Design flaws in QT? by kevin_conaway · · Score: 1
      Returning a negative number for failure would have been better- you don't have to worry wether 0 means an empty file or an error, it would always mean an empty file, and

      If you're talking about C++, you should really be throwing an exception for errors (otherwise known as exceptional conditions). Return codes went out of style a long time ago and are considered poor design when you have alternatives

    4. Re:Design flaws in QT? by kevin_conaway · · Score: 1
      Returning a negative number for failure would have been better- you don't have to worry wether 0 ltmeans an empty file or an error, it would always mean an empty file, and < 0 would always mean an error. You could also then return different negative numbers for different error conditions. It may have a work around, but its a poor design.

      If you're talking about C++, you should really be throwing an exception for errors (otherwise known as exceptional conditions). Return codes went out of style a long time ago and are considered poor design when you have alternatives

    5. Re:Design flaws in QT? by whoop · · Score: 1

      If only you could just have the source code to something like this, then you can "fix" it just how you like it. Ah well, just a dreamy afternoon for me...

    6. Re:Design flaws in QT? by gnuman99 · · Score: 1

      Exceptions are bad for two reasons:
          * they are verbose - I don't want to write by try .. catch blocks all over the place.
          * they are used as a crutch

      Anyway, this is not a design error. If you want to know what the size of a file is, first check that it exists, if it does, open it. Seek to the end and check your position. You are done. It is not a big deal.

      Now I do use exceptions all the time in C++ and Ruby, I just don't want to have exceptions thrown by the library left and right and I have to handle all of them. I always see stuff in Java about unhandled exceptions. Exceptions thrown by libraries are good on paper, bad in practice. And no, Ruby exceptions are not the same as Java. I do not get an exception on non-critical failures (ie. can't open file, socket can't be allocated, etc.). I get exceptions for programming errors (bad input to functions, etc..). For everything else there are return objects. And this is how it should be.

      So in summary, the function in question is not a design error in Qt. You can determine the souce of the failure with other calls.

    7. Re:Design flaws in QT? by Anonymous Coward · · Score: 1, Informative

      QFileInfo claims to (and appears to) use caching, so while "i.isFile();i.size()" looks like a race condition, it's really not, right?

      But doesn't getting all the information about a file require more than one call? stat() will get you length and such, but not the value for readLink(), no? So isn't that still a race condition?

      It's not at all obvious from the QFileInfo docs what is atomic, and when you're writing filesystem code that's kind of important.

      (I've written large programs in Qt, and yes, they've made some rather, ah, "interesting" design decisions.)

    8. Re:Design flaws in QT? by bit01 · · Score: 2, Informative

      Use QFileInfo::isFile to determine if the file exists, then QFileInfo::size returns the file size in bytes, or 0 or if the size is 0 or if the size cannot be fetched.

      This is buggy. It is a race condition. If the underlying file is deleted or renamed or is replaced by a named pipe in between those two calls the return from both calls is inconsistent.

      This sort of error is unfortunately endemic in GUI code, not just qt, and is a large part of why GUI programs, are often flakey. GUI libraries usually have crappy kitchen sink API's that encourage bad programming practices; almost requiring numerous race conditions and potential security holes unless heroic programming efforts are made to avoid them. The kitchen sink API's are an attempt to improve productivity however a lot more care needs to go into their organisation to discourage bad programming practices, particularly race conditions. In this case they should've guaranteed the caching of all of QFileInfo so that all the information about the file is atomic, making race-free programming easier. Better, they should've had a handle to the file that guarantees that whatever operations are done on the file refer to the same file, including file operations outside of QFileInfo.

      ---

      Don't be a programmer-bureaucrat; someone who substitutes marketing buzzwords and software bloat for verifiable improvements.

    9. Re:Design flaws in QT? by Anonymous Coward · · Score: 0

      > Anyway, this is not a design error. If you want to know what the size of a file is, first check that it exists, if it does, open it. Seek to the end and check your position. You are done. It is not a big deal.

      Wrong. This has a race condition: the file might be deleted, have its permissions changed, etc between when you execute the stat/existance check and when you open it. This will also fail on files where you don't have sufficient permissions to seek to the end. (Also, you should close the filehandle you opened, so you're not really 'done' despite the claim above).

      In the particular example you give, you'd be better off using stat, which can tell you the file size, save you from the race condition, and save you from opening a file, seeking, and then closing it.

      In general, trying to determine the cause of an error after it occured in an ad-hoc way is a doomed approach.

      > Exceptions are bad for two reasons:
              * they are verbose
      Exceptions are generally less verbose than explicitely checking return codes all the time. It's more verbose to write code that handles exceptions vs code that doesn't handle errors as indicated by return values, but that's hardly a fair comparison.

    10. Re:Design flaws in QT? by Anonymous Coward · · Score: 0

      In most good documentation that I've encountered for Java and C#, it usually says to use return codes for those sort of conditions that may be encountered but aren't really 'exceptional' - I'm on the fence whether problems in the opening of a file are really that exceptional. Certainly a problem while already having it open and reading it would be (except for EOF - always bizarre that the EOFException is used as a key part of lots of file reading in Java).

      I will admit however that it can make code cleaner and easier to read to just use exceptions and avoid return codes altogether. I think it only really matters a lot to avoid exceptions if possible in code that's being executed often, in loops, etc.

    11. Re:Design flaws in QT? by NormalVisual · · Score: 1

      This sort of error is unfortunately endemic in GUI code

      It's not just limited to GUI code - some bugs in otherwise plain-vanilla multithreaded code are *hard* to track down because a lot of people don't stop to consider that the system can usually switch away from the current thread any damn time it feels like it, and you have to actively take steps to make sure the state you think you're in and the state you are in coincide with each other.

      --
      Please stand clear of the doors, por favor mantenganse alejado de las puertas
    12. Re:Design flaws in QT? by feronti · · Score: 1
      If you're talking about C++, you should really be throwing an exception for errors (otherwise known as exceptional conditions). Return codes went out of style a long time ago and are considered poor design when you have alternatives


      Now, if only I could convince my project lead of that. Had to totally uglify the interface of the component I was working on because I couldn't throw exceptions. Never mind that there was absolutely no way my component could handle any errors.
    13. Re:Design flaws in QT? by tfried · · Score: 1

      This is buggy. It is a race condition. If the underlying file is deleted or renamed or is replaced by a named pipe in between those two calls the return from both calls is inconsistent.

      Oh, come on, now. Yes, this particular function could have easily been improved so you get status and size in a single call. Yes, having two calls is a potential race condition. But no, this race condition is not something you could trivially avoid, here. Hey, whenever you have any information about a file, retrieved by whichever means, it's entirely possible that this information is outdated due to a race condition - before it has even been returned to your code. If you do manage to get status and size of a file at the same time - so what, both pieces of info must be assumed to be outdated in the very next step, either way.

      Qt does the best possible to deal with this: It does not crash just because a file that existed a split-second ago was removed by some other process. Not if you try to read beyond the filesize, not if you try to remove a non-existent file, etc. Apart from not crashing, there's fairly little to be done in the absence of file locks.

    14. Re:Design flaws in QT? by tfried · · Score: 1

      Sure, I could write an application using QT, but I wouldn't know how to handle failures simply because QT doesn't document the behavior in those cases.

      I assume you're not writing too many applications at all, then? You can say a lot about Qt, and the example you give (of bad design, not bad documentation) is certainly valid. But documentation? I dare say Qt is among the top few libraries in terms of both quality and completeness of documentation.

    15. Re:Design flaws in QT? by AuMatar · · Score: 1

      Oh god no. Throwing exceptions is poor style, especially for normal error conditions. Exceptions hould only occur when something totally unpredictable and unrecoverable like out of memory occurs. Exceptions are performance bottlenecks, lead to ugly, verbose code, and spaghetti like error handling. They should never be used for anything that can be anticipated and handled in other manners.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    16. Re:Design flaws in QT? by AuMatar · · Score: 1

      Its rather difficult to fix a key system library's interface. It would cause minor problems like, oh, breaking every other program that uses the library. I could submit a change easily, but it would need to be accepted for the next interface revision, and would likely not be accepted until a major revision as it would break all existing clients.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    17. Re:Design flaws in QT? by fnj · · Score: 1

      "Throwing exceptions is poor style, especially for normal error conditions. Exceptions hould only occur when something totally unpredictable and unrecoverable like out of memory occurs. Exceptions are performance bottlenecks, lead to ugly, verbose code, and spaghetti like error handling. They should never be used for anything that can be anticipated and handled in other manners."

      Bzzzt. Wrong. Thank you for playing.

      Like most dogmatic, arbitrary, rigid, "I have seen the light" rules, this one has poor applicability to C++, which is a many-sided non-theological programming language. Unlike many other recent languages which have been promoted as panaceas, C++ gives you a variety of paradigms. You have not only object oriented programming using classes, you also have procedural, free-standing functions and variables. You have not only references, but also pointers. You can use bare naked pointers, or wrappered "smart" pointers. You have "new/delete", which are very structured, but still also "malloc/free", which are free form.

      And you have exceptions.

      Use these tools in each case where they offer you advantages in whatever programming problem you are tackling. Dogma will not help you as much as free thinking and willingness to explore various approaches.

      There are three particularly important and valuable properties of exceptions:

      (1) They allow directly handling the exceptional condition at the point best suited to handle it: not necessarily the caller, but maybe several levels above. With proper coding discipline, you can readily ensure via methodology - not tedium - that all the intermediate levels in the call chain are cleaned up perfectly when the exception is thrown. This is far from spaghetti coding; it is much more straightforward than laboriously passing an exceptional condition up through layer after layer of calls. Not much is more depressing (and error prone) than writing code where the caller checks a return value, and if an error condition is indicated, returns to his own caller, who then does the same thing, for who knows how many levels.

      (2) They are an out of band reporting mechanism. In case the return code is an unsigned integer type, which counts from 0 to +n, where every one of those values is valid for the quantity being returned, you can't very well reserve any of the possible values for an error report. Well, you can do so, but then you have a suboptimal solution like the one being discussed, where you can't tell if 0 is an error or the actual valid value. Absent exceptions, you must then resort to returning a structure containing the value plus an error code, or you must return one or the other separately via a reference parameter.

      (3) The user is protected against ignoring the exceptional condition. If it's just a return code, the caller may not check it, and no one will ever know when the exceptional condition occurs. There is no chance to fix code when you have no indication that it is wrong. Exceptions, on the other hand, if ignored, will by default terminate the thread or process. That will get noticed, particularly if you use set_terminate to arrange for logging and then making sure the entire process terminates. Better yet, put a try/catch (...) at the very top level of each thread.

    18. Re:Design flaws in QT? by AuMatar · · Score: 1
      They allow directly handling the exceptional condition at the point best suited to handle it: not necessarily the caller, but maybe several levels above.


      In other words: they allow people to write completely unstructured spaghetti code thats impossible to maintain. ANyone who uses exceptions for this needs to be fired immediately.

      They are an out of band reporting mechanism.


      They're a poor implementation of this. The correct way to handle out of band data is to allow a function to return more than one piece of data (for example, allow a function to return 2 ints. A function would look like int int foo()). The C++ standards comittee screwed up here. While exceptions do fill this gap, they are the worse way possible of filling it.

      The user is protected against ignoring the exceptional condition


      BZZZZT!!!! The type of moron who ignores error returns will just as routinely put everything in a try block and catch (...). So this is a strawman.

      Sorry, there's no two ways about it. Exceptions are a language flaw, not a feature.
      --
      I still have more fans than freaks. WTF is wrong with you people?
    19. Re:Design flaws in QT? by fnj · · Score: 1

      I can understand that you may not be ready to grasp the concepts, but it might be better to either provide supporting logic for your assertions, or else forego making the assertions altogether.

      If you are going to assert that "exceptions are a language flaw", that flies in the face of widely accepted practice. Just about every serious language of reasonably modern vintage implements them; they are an accepted staple. If you are going to go against overwhelming mainstream thought, you are going to need some semblance of reasoned logic or your viewpoint is going to be dismissed by serious professionals.

      As for your last point, comparing an error of omission where someone forgets to check an error return, to a "moron" who goes to great lengths to deliberately subvert exceptions, is just plain silly on the face of it.

    20. Re:Design flaws in QT? by angel'o'sphere · · Score: 1

      Exceptions are performance bottlenecks, lead to ugly, verbose code, and spaghetti like error handling.
      This is complete bullshit.

      In modern C++ Exceptins have nearly zero overhead. And I really can't see why an if (error == code) .... else if () chain is less spaghetti than catch (X x) .... catch (Y y).

      Error Codes are EVIL. Exceptions not.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  20. Re:subject by thsths · · Score: 1

    > This is exactly why I dropped Linux and went to OS X - the 4th major revision sports feature such as better basic-string handling (!!) and better programming APIs.What about overall user experience[?]

    Qt is a toolkit, that means a tool for programmers. So it is only natural that is provides a better *programming* experience. If you want better user experience, you have to wait for an end user program. And I am sure that KDE 4 will deliver exactly that.

  21. Re:gui and native code - bad combination by dreamlax · · Score: 1

    What I sometimes do is write the performance-critical parts of my program in a low-level language, usually C or C++, and bind it with Python, and have pyGTK or pyWidgets for the GUI. It gets messy handling two languages, but doing a GUI in a high-level language like Python hugely reduces GUI development time. It can also be a little boring, if not tedious, to mix C++ and Python too...

    Have you ever developed a GUI for a Windows app in C++? They may well have just invented their own C++ standard... it's crazy. I developed GUI apps in VB before going to C++, before finally wiping Windows and using Linux, and even writing a GUI in wxWidgets is by far easier than Windows. wxWidgets can even take care of the main() entry point (or WinMain or what have you). In Windows, I think you required about 50 or so lines of code for a "hello world" (wxWindows isn't many lines less but it is much easier to read and follow). Horrible. Wouldn't touch it again with a 40-foot pole.

    I haven't tried Qt primarily because Gnome's always been the default desktop on the distro I installed, but instantaneously I can conclude it's better than Win32 GUI programming.

    DirectX is another issue... woah! I wouldn't go there again either. Once was too much. It's like taking the mangled C++ code you wrote for a Win32 GUI, mangling it further, making sure pointers are passed around like free pizza, and somehow have it spit out some form of 3D graphics and sound. To try and follow DirectX code was to me like being blind and walking through a maze, you'll eventually get there, but only after much, much effort. Maybe it's just me, but I cannot believe I ever wrote programs like I did and thought I was doing it "right".

    Not trying to belittle Microsoft's programming standards or anything... cough..

  22. Re:gui and native code - bad combination by BravoZuluM · · Score: 1

    You haven't used QT based on your comment. You don't use malloc. QStrings and QByteArray hide the inner workings of string manipulation, slots and signals make event handling trivial and the layout managers just work.

    I've done alot of GUI development going back to System 7 on the Mac, OWL, MFC 1.0, MacApp, ET++, Starview..ect.

    QT is by far the best C++ UI (and more) development environment for doing cross-platform development. And, it's a better ActiveX development than ATL or MFC.

    M

  23. I know this maybe off topic by Anonymous Coward · · Score: 0

    But are there any good books for GTK and libglade or am I behind the times? Also, I am not talking about gnome. I would like to stay out of the gnome api and just use gtk to build a small interface but I have never attempted this so I was looking for some pointers...

  24. Re:gui and native code - bad combination by Henry+V+.009 · · Score: 1

    I agree with the higher the better approach. On the other hand, a person calling malloc while coding in C++ probably doesn't know C++. Nor are C++ strings like C strings. Handler and callback routine setup is generally handled by the library you use (QT has a nice slots and sockets implementation. Boost also has a library devoted completely to that which can be dropped into other projects.) The "layout-bag-grid-column" will depend on whatever library or API you are using, not the language.

    C++ is not C by any stretch of the imagination. It's a multi-paradigm langauge (that's both the best and worst thing about it). If there is a programming methodology out there, C++ probably supports it. Although it'll be nice if functional programming gets some help with C++0x -- Boost Lambda doesn't really cut it.

  25. Qt: creating a larger commercial/libre wedge by Anderlan · · Score: 1

    Trolltech provides the library in two licences - the free licence which mandates that the applications developed be released under GPL and a commercial non-free licence which allows one to develop closed source applications using Qt.

    Does anybody know what the terms of the closed license actually are?

    With LGPL'ed libraries (gtk, etc), I can make a program and flirt with selling it; that is, I guess, I can experiment with distributing something as shareware. With Qt, I might have to shell out something to Troll before I make the first penny, or at least I have to have a talk with them.

    Wait a minute. Nevermind GTK. I don't even have to do that with Microsoft Windows libraries, either!! Also with GTK and Windows, I can go on past the shareware stage and sell the next big killer app and not pay anyone anything. (Well, MS will target me and destroy me on Windows, but I will have gotten farther without harrassment than I did with Qt.)

    --
    KLAATU, BORADA, NIh*ahem*
    1. Re:Qt: creating a larger commercial/libre wedge by Jerry · · Score: 1
      Does anybody know what the terms of the closed license actually are?


      Our commercial license cost about $3,300 US for one developer and includes one year of email support and acess to the latest updates and releases at no charge. Which, I should add, is very good.
      With that license you get connectivity to all the major databases, and a license to distribute binaries of your app for either Windows or Linux. In my experience QT is an excellent development library.

      --

      Running with Linux for over 20 years!

    2. Re:Qt: creating a larger commercial/libre wedge by Almahtar · · Score: 1

      I'd argue that it's improbable you'd write for windows and not spend a penny. Sure, you can develop .NET applications with nothing more than notepad and the command line, but it'd be a lot like building a 10 story card castle.

    3. Re:Qt: creating a larger commercial/libre wedge by Blakey+Rat · · Score: 1

      The "Express" versions of the .net programming tools are free, and they are complete-enough to write full applications with. As far as I'm aware, there are no restrictions whatsoever on applications you write with (say) VB.net Express.

      Now, the "Express" versions are missing some things, so you're correct in that developing with them would be harder than with the commercial versions, but it is certainly possible and a ton easier than Notepad.exe.

    4. Re:Qt: creating a larger commercial/libre wedge by NormalVisual · · Score: 1

      I'm not trying to stir the pot, and I'm also not a Microsoft fanboy, but what Qt offers for that $3300 absolutely pales in comparison to what you get with a VS 2005 Pro/MSDN Premium subscription for $800 less. I've yet to see anything in the Linux world even approach the quantity, quality, and organization of documentation that MSDN offers. It's almost like trying to drink from a firehose.

      Of course with MSDN you're limited to Windows, but on the other hand there's plenty of stuff Qt doesn't abstract for which you might have to write system-specific code anyway. For instance, if you wanted to do a really spiffy audio app, you certainly could do a cross-platform UI with Qt, but you'd still have to write for ASIO or DirectSound in Windows, JACK in Linux, and Core Audio on the Mac, and none of those understand any of the Qt types.

      Certainly if you can do enough volume on your software sales, it's worth it to buy a Qt license for each developer. For most people I've talked with however, the price is just out of line for what you get and in my experience often results in Qt being passed over for something less capable but much easier to justify financially like GTK or Wx. I'm not busting on Qt for their pricing - if that's what it costs Trolltech to continue development of Qt and provide support, then that's what it costs and they have to do whatever is in their best interests. That's really not the customer's problem, though.

      --
      Please stand clear of the doors, por favor mantenganse alejado de las puertas
    5. Re:Qt: creating a larger commercial/libre wedge by angel'o'sphere · · Score: 1


      I'm not trying to stir the pot, and I'm also not a Microsoft fanboy, but what Qt offers for that $3300 absolutely pales in comparison to what you get with a VS 2005 Pro/MSDN Premium subscription for $800 less.

      I can't second that. MSDN is often vague, outdated or has no support to known issues at all.

      $3300 is only about 3 to 4 days of a developers sallary and extra costs like housing, insurrances etc. So if a developer saves 3 or 4 days per year with using a better API and tool chain it easy pays off.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  26. gtk? by edmicman · · Score: 1

    Not to stir anything up, but how does Qt compare to GTK? Could things like gaim or GIMP be redone in Qt (mostly gaim as I think GTK is a whole lot of the reason it takes up so much memory in Windows)? What kind of project would that be? Maybe I'll have to check it out and throw together a simple app or something.

    1. Re:gtk? by SirTalon42 · · Score: 1

      Of course. Skype is written in Qt (not sure if its Qt3 or Qt4 off the top of my head), Kopete is a KDE IM app similar to Gaim that is written using Qt/KDE, Psi is a Jabber client, I think GTalk is also written in Qt.

      Lots of programs already use Qt (including Google Earth, and Opera).

    2. Re:gtk? by Dasher42 · · Score: 1

      It wouldn't be so eaasy to redo GAIM or Gimp in Qt. What you can do to force the essential features of GUI programming differs from what is considered good practice in C++. Besides, the Qt applications are often KDE-oriented, and it makes no sense not to leverage that framework when you can, and get a more consistent, interoperating environment. So, instead of rewrites, you have Kopete and Krita. Sometimes programming libraries get shared, as with Beagle, but that's about it.

      I'm more of a C++ and Python guy, so I like what Qt has under the hood, but you're best off leaving programmers to use whatever they're most effective in, rather than try to tell them which is better.

      Besides, I get a kick of using gtk_qt and making all my GTK apps draw with Qt without worrying about any inconsistency of themes. :)

    3. Re:gtk? by Anonymous Coward · · Score: 0

      With the release of KDE4, kdelibs will be fully cross-platform. I expect that most core KDE programs will be recompiled for Win32, and the few Windows GTK programs will gradually fade away. In all likelihood, Kopete will fill the niche which Gaim does now. And no one uses The GIMP anyway. :P

      (I don't mean to insult Gaim, of course -- Kopete itself is powered by the libgaim library. But as bad as GTK is on Linux, it's far worse on Windows... which is why no one in their right mind would write a GTK app for Windows when there's a far better alternative.)

    4. Re:gtk? by bcmm · · Score: 1

      Porting kdelibs doesn't really mean that all KDE apps can straight away be ported to Win32 because many of them depend on non-KDE libraries which may not be cross-platforum. The Amarok team, for example, have stated that they will not try to port Amarok, because Windows lacks the multimedia libraries that Amarok uses (imagine Amarok with WMP engine support *shudders*).

      --
      # cat /dev/mem | strings | grep -i llama
      Damn, my RAM is full of llamas.
    5. Re:gtk? by JabberWokky · · Score: 1
      You realize that Qt is far more than a GUI library, correct? It has database engines, multiprocess communication handlers and even fundimental components like a powerful string library. Non-GUI applications like daemons and CLI programs can use Qt.

      --
      Evan

      --
      "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
    6. Re:gtk? by Dasher42 · · Score: 1
    7. Re:gtk? by Abby+The+Wonder+Dog · · Score: 1

      Bad example. The Amarok guys stated very recently that they are going to do a port to Windows. Listen to Episode 151 of the Linux Links Tech show. One of the devs has to use Windows at work and wants to use Amarok while he is working :-)

      http://tllts.org/archives/tllts_151-08-02-06.mp3

    8. Re:gtk? by Dr.+Sp0ng · · Score: 1
      Not to stir anything up, but how does Qt compare to GTK?

      API-wise, Qt is far superior. GTK is a horrible API, and requires way too much typing to get anything done. Qt is a nice, clean C++-based API that's pretty nice to use. The upside of GTK is that it's much easier to use from non-C++ languages*.

      From an end-user standpoint, GTK is pretty decent. I'm not sure I see the benefit in rewriting a GTK app in Qt, or vice versa.

      * Before anyone gets bent out of shape, I've been using both toolkits for a long time... writing open source (and a little paid work) with both in the 90's, and several full-time and contract jobs in this millenium writing Qt code.

      Could things like gaim or GIMP be redone in Qt (mostly gaim as I think GTK is a whole lot of the reason it takes up so much memory in Windows)? What kind of project would that be?

      Well, seeing as how GTK stands for GIMP Toolkit (or used to, anyway... I don't really pay much attention to this stuff anymore, but it was originally written specifically as an interface toolkit for GIMP), GIMP is pretty tied to it. And in any case, GTK and Qt are really pretty different beasts - Qt is a pretty clean system of C++ classes, with a preprocessor to add some (very handy) syntactic sugar, while GTK-based programs spend much of their time and effort trying to work with a class hierarchy shoehorned into C. Programs written in GTK have a very different flow than those written in Qt.

      As for memory usage, if GTK is using more memory than the pixel buffers in GIMP, something's very wrong.

    9. Re:gtk? by Carewolf · · Score: 1

      Amarok has a multimedia abstraction engine, and are going to write a DirectSound/Music backend for it. The new KDE4 Phonon framework is also a multimedia abstraction framework and is also going to use native sound on Winodws (if we can find someone to write it).

    10. Re:gtk? by ForeverFaithless · · Score: 1

      In fact we (Amarok team) do plan to make Amarok 2.0 work on Windows natively. Your information is a bit outdated.

      --
      Mark Kretschmann - Amarok Developer, KDE Member
    11. Re:gtk? by bcmm · · Score: 1

      Sorry about that... Was there was a previous announcement stating that there wouldn't be a port? I seem to remember reading something around the time that the kdelibs port was announced (so yeah, I was pretty out of date). I hadn't heard about Amarok 2.0.

      --
      # cat /dev/mem | strings | grep -i llama
      Damn, my RAM is full of llamas.
  27. Qt for non-GUI apps by Dasher42 · · Score: 1

    It's important to point out that the core libraries of Qt, with the signal/slot mechanisms and base containers and classes, are now decoupled from the GUI libraries. This is now a good general purpose thread-safe programming library. It strikes me that signals and slots supply the advantages of weak binding, much like in Objective C and Smalltalk, and you almost wish the language had had libraries like this all along.

    I for my part am very interested in PyQt or some other approach of wrapping Qt into Python as such. This could make for some very rapid development, with Python prototyping and scripting, not to mention the way you can have either C++ or Python objects receive Qt signals. Has anyone experimented with this approach? Any comments on the overhead and ease of use?

    1. Re:Qt for non-GUI apps by Pseudonym · · Score: 1

      If this is what you want, you're better off using Boost than Qt. The GUI library is what makes Qt great. If you just want a foundation library for smart pointers, signals/slots, containers, threads and a bunch of stuff that it never occurred to you that you might need, Boost is far, far superior.

      Not only is Boost exception-safe (which almost none of Qt is), but today's Boost library is tomorrow's C++ standard library. Boost prepares you for the future.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  28. Qt in an Embedded (Non-Linux) Environment ? by Anonymous Coward · · Score: 0

    Hi,

        Sorry for posting Anonymously, but I've always been more of a lurker.
        Hopefully someone will read this, think it's worthy of discussion, and mod it up.

        Anyway -

        As an embedded developer, I'm stuck with the OS that my company has historically used (AMX).
        We've used PEG for our UI work, thus far.

        I see this: http://www.trolltech.com/products/qtopia, but it seems very Linux-specific.

        I'd like to evaluate Qt for use in an embedded device, but I won't be able to run it on Linux.
        Is it portable? How difficult would it be to get it running on another (non-Windows) OS?

    Thanks!

    1. Re:Qt in an Embedded (Non-Linux) Environment ? by Millenniumman · · Score: 2, Funny

      You'll have to enable the string parsing concatenation recompilation matrix kit, and possibly the array flattening engine libraries. If you want a GUI, you'll need to pass the build argument "QT_UNDECELERATE_FRAMEWORK". If your OS runs a non-57 bitrate clock register, you'll need to use type 874r function register matrix libraries. When you build you'll need to bypass kernel remapping protocol structures to endianize the unclock processor. Other than those steps, it shouldn't be too hard.

      --
      Stupidity is like nuclear power, it can be used for good or evil. And you don't want to get any on you.
    2. Re:Qt in an Embedded (Non-Linux) Environment ? by Anonymous Coward · · Score: 0

      Thanks for the non-help, jackass. Anyone want to provide some real info?

  29. Use composition instead of inheritance by amightywind · · Score: 1
    As such, you don't want to be saddled with a language which requires you to think about every malloc(), to manipulate strings of characters as bytes, to set up event handler callback routines, or to call methods on layout-bag-grid-column junk.

    You make a very good point. Most programmers do not make the effort to seperate UI elements from their callback infrastructure because they use inheritance to compose functioning widget heirarchies. So they combine program context with their UI. If you use composition you will be much better off, and it is easy. Create a "spineless" GUI mockup for your boss. The code should contain minimal dependencies beyond Qt or wxWidgets or whatever you are using. Implement your event handlers with minimal knowledge of the UI and attach them dynamically. With older toolkits in C you only have callback hooks so this is easy.

    --
    an ill wind that blows no good
  30. Re:gui and native code - bad combination by iangoldby · · Score: 1
    As such, you don't want to be saddled with ... layout-bag-grid-column junk.

    You want to build up that layout graphically...

    The trouble with drag-and-drop UI designers is that the layout tends to break horribly when the window is resized or the font size changed. (I'm talking about VB, Delphi, and MFC here - there may be other frameworks that have found a way around this problem.) Designers who try to solve the problem by making their forms non-resizable should be taken outside and shot...
  31. Re:gui and native code - bad combination by Phisbut · · Score: 4, Informative
    I agree that if I want to put a label in a window, I dont want to have to handle its deallocation, i.e. I want a "fire-and-forget" feature. I accomplished this in my wrapper by letting the parent deal with its children.

    Well, that is exactly what Qt does. Every time you create a widget, you pass a pointer to its parent, and then you can forget about the widget. When the parent dies, it'll kill all of its children, and then they'll kill their children too in cascade. I do tons of Qt programming (that's what we use where I work), and memory management of Qt widgets is a breeze, every widget is hierarchically created, and I just need to kill the window when I don't need it anymore to have it kill all its widgets and sub-widgets. No need for a custom-made wrapper, it's all in there already.

    --
    After 3 days without programming, life becomes meaningless
    - The Tao of Programming
  32. Re:gui and native code - bad combination by Jerry · · Score: 1
    As such, you don't want to be saddled ith a language which requires you to think about every malloc(), to manipulate strings of characters as bytes, to set up event handler callback routines, or to call methods on layout-bag-grid-column junk.


    It's obvious you've never used QT4.1.x/C++, or you wouldn't be mentioning malloc(), etc.


    If I were to compare coding with the QT4 API to anything it would be Java on steroids. QT uses MOC, a meta-object compiler, to convert gui/api dependent coded to pure C++. Classes with the QOBJECT in it have automatic access to automatic memory management and garbage collection. Of course, if you use NEW its up to you to use DELETE before your method goes out of scope.

    What is really nice is that I have written an app using Microsoft VC++ 2003/Qt on Windows against Oracle and compiled it on Linux against PostgreSQL with no code changes, using compiler defines to switch in and out the proper syntax at the appropriate places. It's an in-house app currently used in production. Saying it is lightening fast is an under statement.

    --

    Running with Linux for over 20 years!

  33. Bookpool has it even cheaper by Anonymous Coward · · Score: 0
  34. Move over Qt by Anonymous Coward · · Score: 0

    crosss-pltfrm MFC roolz !!!

  35. Re:gui and native code - bad combination by vdboor · · Score: 1
    The trouble with drag-and-drop UI designers is that the layout tends to break horribly when the window is resized or the font size changed. (I'm talking about VB, Delphi, and MFC here - there may be other frameworks that have found a way around this problem.) Designers who try to solve the problem by making their forms non-resizable should be taken outside and shot...
    that's something Qt has solved too, you can define the layout contraints in the designer directly. See it in action with this video: http://www.trolltech.com/trolltech/products/qt/lea rnmore/video/demos/browser
    --
    The best way to accelerate a windows server is by 9.81 m/s2 ;-)
  36. Re:gui and native code - bad combination by PeterBrett · · Score: 1
    What I sometimes do is write the performance-critical parts of my program in a low-level language, usually C or C++, and bind it with Python, and have pyGTK or pyWidgets for the GUI. It gets messy handling two languages, but doing a GUI in a high-level language like Python hugely reduces GUI development time. It can also be a little boring, if not tedious, to mix C++ and Python too...

    Check out PyQT.

  37. Re:gui and native code - bad combination by quintesse · · Score: 1

    "If I were to compare coding with the QT4 API to anything it would be Java on steroids"

    You mean, that's why they implemented so many Java-like features in version 4, so they could call it Java on steroids?

    Or is it maybe because they took a look at Java and went "hey, there's a lot of cool stuff i there, we can use that as well!" ;-)

  38. Its too bad its not LGPL by DrDitto · · Score: 1, Interesting
    The Linux desktop would be further along if QT were LGPL instead of GPL. Requiring a multi-thousand dollar license is fine for anything besides platform software, which is why QT can never be incorporated as a core Linux platform library (like glibc).

    Case in point: I am at a university and we write software for research. We cannot release the source for various reasons, but we also do not sell the software and our goals are strictly academic. And I can't justify the license fee to the PI (principal investigator) given the alternatives. Heck, even Microsoft Visual Studio is substantially cheaper.

    Flame away. I always get flamed for this argument.

    1. Re:Its too bad its not LGPL by Anonymous Coward · · Score: 0

      > Flame away. I always get flamed for this argument.

      And rightfully so, as Trolltech has special license offers for universities.
      Just contact Trolltech to find out more.

    2. Re:Its too bad its not LGPL by babbling · · Score: 1

      If you can't release the source code, I'd rather you didn't release the executable code, either. I'd also rather you can't use Qt in that case, because then you have to put up with awful Windows API crap.

    3. Re:Its too bad its not LGPL by penrodyn · · Score: 1

      Academic licences are still expensive for research groups and one has to pay out on them every year (for ever essentially if you want to support the application). I had the same problem as the previous poster, had to drop QT in the end, now we're (as someone said) using the crappy (I agree that the GUI API is still a bit immature), but free and relatively usable Windows API (using mono for portability).

    4. Re:Its too bad its not LGPL by Aladrin · · Score: 1

      I'm probably going ot get modded troll, too, but oh well.

      I can't speak for the academic stuff, but there's a grandchild of your post that does it well enough, I think.

      As for the GPL/LGPL... I definitely agree. Free software licenses should be about freedom. GPL -forces- you to GPL your code, too, and that limits my freedom.

      I was reading the summary right up until I read the part that states the free version requires your app/game/whatever to be GPL. I know that's just standard GPL stuff, but it's not acceptable to me. If I want to give my hard work to the community, I should be able to do it under any terms I wish.

      --
      "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
  39. Re:gui and native code - bad combination by Anonymous Coward · · Score: 0

    C++ with MinGW and QT in the Eclipse IDE. Easy peasy

  40. So... by Pseudonym · · Score: 1

    So where's the chapter on exception safety? No, I didn't think so.

    Qt does not play nice with C++. If all I want to write is a GUI, Qt is great. If I want to write a program with a GUI and other functionality that requires other C++ libraries, I'm stuck with a huge impedance mismatch.

    "C++ GUI Programming with Qt 4" is a misleading title. You can either write a C++ program, or a Qt program. Not both.

    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  41. Re:gui and native code - bad combination by oopsdude · · Score: 1

    I agree with your assertion in general that high-level languages are better for GUI development, but:

    GUIs are a fluid, flexible, dynamic, change-on-the-fly, subject-to-change, feedback-driven kind of feature.
    You're absolutely right, despite being a bit redundant. As someone who has used many languages myself, I can tell you that I can implement just that kind of GUI in almost language that I know. But just because you might pick Python over C++ because it's a high-level language doesn't mean that Python can magically "adapt" better to varying user input. Nor is C++ worse at being dynamic, or more concrete, simply because it compiles to native code. Programming languages are not adaptable that way, because no language is sentient. The programmer still has to tell the language what to do in each situation the program might encounter. Building a dynamic, feedback-driven GUI has less to do with what language you choose and much more to do with your programming skill.

    The rest of this is just semantics:

    you don't want to be saddled with a language which requires you to think about every malloc()
    I definitely wouldn't want malloc anywhere in a well-constructed GUI. But I might be wrong here.

    to manipulate strings of characters as bytes
    So use C++'s string class. As for C, well, you get used to it. It's really not that bad, if you know what you're doing. (I'd recommend against using C for GUI work, though.)

    to set up event handler callback routines
    I've never seen a GUI toolkit that doesn't use event handlers (although they may exist). Qt uses them, Tk uses them, GTK uses them, Swing and Awk use them, even Javascript uses them. You can't get much higher-level than that.

    to call methods on layout-bag-grid-column junk
    If you take the time to understand it (it's not hard, and there's plenty of documentation), container-based layouts work beautifully. Many high-level language GUI toolkits use them. Or you could use something like WinForms. To each his own.

    You want to build up that layout graphically
    Huh? You mean by drawing it out first? UML? Using one of those drag-and-drop GUI generators?

    name the elements appropriately
    That has absolutely nothing to do with what language you use.

  42. Your learning experience will not be a killer app by dbIII · · Score: 2, Insightful
    Simple - you learn on the free version. If you are good enough you can then go commercial with a completely closed application and make money - but you have to feed the people who work at troll a bit too with some of this in the form of a licencing fee. If you are not sure it is good enough or you don't want to go through the hassle of convincing people to buy your stuff you release a completely open application. There is too much crap shareware in the world already - even if you write a gem how will people find it?

    However, there may be some cut price licences out there for shareware or you probably can turn your software written on the GPL Qt into the commercial version if you have never released the software and you get a commercial licence. Perhaps look at their website - I've only looked at their GPL stuff.

  43. Save $10.20 by buying the book here! by Anonymous Coward · · Score: 0

    Save yourself $10.20 by buying the book here: C++ GUI Programming with Qt 4. And if you use the "secret" A9.com discount, you can save an extra 1.57%! That's a total savings of $10.79, or 22.82%!

  44. Mod parent up by HR · · Score: 1

    Thank god for a response from an actual programmer who know wtf exceptions are used for in C++. I cannot believe people are making excuses for broken functionality in a popular library. Someone points out that a class library is broken in one respect and others say, "so what, do this instead".

  45. What do you mean? by twitter · · Score: 1

    Qt does not play nice with C++. If all I want to write is a GUI, Qt is great. If I want to write a program with a GUI and other functionality that requires other C++ libraries, I'm stuck with a huge impedance mismatch.

    Are you telling me that I can't pass values between Qt classes and those written by others? Can you give me some examples? I was thinking that Qt's double buffering and OpenGL support would be a nice way for me to put an interface onto some tomography code I'd written. The code is all straight C, and I thought wrapping it up in a class might be nice. Would it be harder for me to call my functions though a class than it would the straight C versions? How do the KDE programmers get around these issues?

    --

    Friends don't help friends install M$ junk.

    1. Re:What do you mean? by Pseudonym · · Score: 1
      Are you telling me that I can't pass values between Qt classes and those written by others?

      The problem is that you can't throw an exception through Qt, or Qt will leak resources (most likely memory). If you want to use any library that throws exceptions (this includes the standard library; even allocating memory in C++ may throw an exception), and you want to do something with the exception other than abort the program, then at the very least you need to insulate Qt from the exception.

      The situation is worse in KDE, because exceptions are turned off completely. You can't even reliably use a library which throws exceptions. (As previously noted, this includes the standard library. Ouch.)

      The code is all straight C [...]

      C doesn't throw C++ exceptions.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    2. Re:What do you mean? by Anonymous Coward · · Score: 0
      The problem is that you can't throw an exception through Qt, or Qt will leak resources
      Did you actually try that out, or is it your guess?
    3. Re:What do you mean? by Pseudonym · · Score: 1
      Did you actually try that out, or is it your guess?

      Neither. It's pretty easy to spot the worst forms of exception non-safety with a code inspection if you know what you're looking for.

      (The reason why I did the code inspection was a failed attempt to integrate a third-party C++ library with KDE.)

      Any code which looks like this is immediately suspicious:

      QSomething* something = new QSomething();

      As is this:

      QMySomething::QMySomething()
      {
      m_something = new QSomething();
      // ...
      }
      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  46. Replace QT with WX! by Anonymous Coward · · Score: 0

    There has been a _totaly_free_ crossplatform GUI API for many years that nobody seems to be talking about, WX.
    Its C++, runs on Linux, Mac, Windows, PDAs and more! It has everything you need and its free for opensource and commercial use.
    Learn at http://www.wxwidgets.org/ . . I used to be intrested in QT, but I realy didnt like the license I had to pay for something I can get for free from WX.

    1. Re:Replace QT with WX! by joss · · Score: 1

      Each to their own. Personally I prefer http://www.fltk.org/

      --
      http://rareformnewmedia.com/
    2. Re:Replace QT with WX! by Anonymous Coward · · Score: 0

      The company I work for holds the very first 2 commercially sold Qt licenses.
      I've worked a lot with Qt myself, the past 6 years
      At this point I'm doing some prototyping with fltk2.

      Qt has become borgish. It provides an environment that does everything and doesn't integrate very well with other things. (you have to use data translators to go between STL and Qt)..

      Qt version 4 trashed the drawing engine. For cad like operations it is totally unacceptable. Additionally they added a ton of classes which dictate coding policy by attempting to tie data up into the Qt code (MVC). GUI toolkits are good at representing and editing states, but they shouldn't be in the business of dictating policy.

      In the past 5 years lgpl & as-is licensed libraries can be combined to do everything Qt does. During that time the cost of Qt licenses & license maintenance has gone through the roof. All of this comes with the above headaches.

      It takes 30 minutes to build the Qt libraries from source. It takes 1 minute to build a full fltk package from source.

      Sure, you lose the nice widget layouts from Qt, but it provides what is needed in an orthogonol fashion. There's not 5 different layers for intercepting and handling of events.

  47. No, thats Sweden by andersh · · Score: 1

    You just have us confused with Sweden.. We love our pretty blonde women over here in Norway - its just that they enjoy sex too much to have babies.

  48. Some Pointers by Uncle_Al · · Score: 2, Informative
    Almost every part of GTK+, from the colors to widget shapes, can be changed in user themes. Qt has no way to do either of these without linking in bloated external libraries.
    Well, I guess then the class QStyle is completely useless....and setting a "usertheme" with qt-config is something I must have dreamed then....*g*

    Until Qt 4, there was no way to load .ui files at run time.
    Ok...but what is the class QWidgetFactory used for then? :-)

    Qt still has no support for "recent documents", requiring the user to keep track of and build this list himself.
    Which is rather easy using QSettings...

    Have a nice day :-)

  49. QT licensing problems by pkphilip · · Score: 2, Interesting

    I have serious problems with the QT licensing model. I perfectly understand that they want to charge commercial developers for using their products. Heck, I won't even mind if they don't have a free version. But what I find absolutely intolerable are the terms of their commercial license.

    The commercial license is tied to a named developer. That is, if I have a developer Dave who needs a QT license, I must buy a named license for Dave. It does not matter if I have unused licenses of QT lying around (which other developers don't need and are not even installed), I must still buy a license for Dave.

    If Dave needs to go on a holiday or just dies and if I need Bill to complete the project using Dave's license, then the terms of the license prevents me from doing that. The license must be transferred over to Bill's name and this can be done only after 6 months! This is completely insane! Why would a company purchase a several-thousand-dollar license for a developer and face the prospect of having to purchase yet another license if the developer leaves the company / is unable to work on the project / is promoted to a non-coding role etc?

    QT's commercial license fees are very high, and separate licenses are needed for each platform - that is, I need to buy QT license separately for Linux, Windows etc. Now, I perfectly understand that Trolltech can charge what they want as it is their product, but I do feel that they have made the product as unattractive an option as possible and this has resulted in huge losses to them. But again, that is their problem not mine.

    I had the opportunity to review cross platform GUI toolkits for a huge project we were working on - the project was a very large public transportation project for Scandinavia and we needed a lot of licenses; I opted against QT (thereby denying them a huge order) because of these very unattractive terms in their licenses. I have had similar experiences with another project for a Finnish client as well. In both cases, I felt that QT was definitely the best framework for the job, but the licensing terms completely wiped out any of the technical advantages.

    The primary problem with the QT commercial license is the fact that it makes it very difficult to bring in developers on a contract into a project for a short assignment. It becomes very difficult to reuse this license with yet another developer once the first developer's contract ends or if the first developer chooses to go elsewhere.

    IMHO, Trolltech has an excellent product, but their legal and marketing departments needs to be overhauled.

  50. Actually there is no race condition by Anonymous Coward · · Score: 0

    Actually by default there is no race condition present due to calling QFileInfo::isFile() followed by QFileInfo::size(). This is because by default QFileInfo caches info about a file.

    http://doc.trolltech.com/4.1/qfileinfo.html:

    "To speed up performance, QFileInfo caches information about the file. Because files can be changed by other users or programs, or even by other parts of the same program, there is a function that refreshes the file information: refresh(). If you want to switch off a QFileInfo's caching and force it to access the file system every time you request information from it call setCaching(false)."

    I wouldn't be surprised if on *nix based platforms a QFileInfo object simply calls fstat on construction.

    1. Re:Actually there is no race condition by AuMatar · · Score: 1

      If you base your code's correctness around implementation details of 3rd party classes like that, you're going to be in a world of pain very shortly. There's no promise that future versions won't query the file again rather than caching the data.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    2. Re:Actually there is no race condition by HR · · Score: 1
      I agree with the development philosophy you espouse: basically, program defensively. In this case, however, what is being discussed is not "implementation details" but rather a broken implementation - a part of the library that simply cannot be used at all if you want to have reliable code. That is the point, it's just broken. The only choice in this case is what everyone is getting hung up on, you have to manually code around that broken part of the library.

      If I have to basically rewrite parts of the library myself, what am I using the library for?