Slashdot videos: Now with more Slashdot!

View

Discuss

Share

We've improved Slashdot's video section; now you can view our video interviews, product close-ups and site visits with all the usual Slashdot options to comment, share, etc. No more walled garden! It's a work in progress -- we hope you'll check it out (Learn more about the recent updates).

Did they make any moves towards using standard C++ features rather than the MOC ugliness? What with Boost::Signals, sigcxx and C++11, I see no reason why they have to bastardise the language to provide signals.

How do you call a C++ method by it's name from QML or javascript or C++ plugin without some kind of pre-prosessing step which actually stores the method names and argument types somehow to make invocation possible?

dlsym(h, "my_method")
There is no need to store it, it's already in the symbol table.

If you do want to store it, there is no need to use an external preprocessor anyway.

That works for functions, but not Class Methods that require an instance of the class. And, even more so, how do you do it in a multi-platform environment in a uniform way? (http://en.wikipedia.org/wiki/Dynamic_loading). Windows doesn't use dlopen/dlsym/dlclose but has its own Win32 functions to do something similar.
You're also relying on RTTI; and not every compiler or environment supported by Qt supports RTTI. (RTTI also has its own run-time overhead which is bad in embedded environments like what Qt sup

It works for any symbol, regardless of its type.
This has nothing to do with RTTI.

The API for plug-ins is platform-specific since there is no standard interface for C++ plug-ins.

Yes, you could use dlsym() when building the table MOC builds for the connector calls. That's it. That's also a very very small part of what MOC does. That could be done as part of the object constructor...except now you need to store both static compile-time information (the functions you want to add) and dynamic run-time information instead of just the static compile time stuff that MOC generates (in the moc_*.cpp files).

RTTI does a good bit of the rest of what MOC does. In neither case are they both supported by all platform+compiler combinations that Qt supports.

Qt5 now allows C++11 lambas in signal/slots; but only if you enable C++11 functionality when you build it - they still support compilers that don't support C++11 lambas.

You're still missing the point. How exactly, given a QObject*, can you ask it to give you some wrapper encapsulating a method named "foo"? Even if you're willing to do C++ name mangling yourself in a platform-specific way, you still need to know the actual type of the object to which you have the pointer, meaning that you need RTTI.

The problem is that the moc implements something more like the Common Lisp Object System's metaobject protocol for C++; resolving symbols at runtime is a tiny portion of what it does. dlsym and analogues on other platforms are also horrendously unsafe; a one way ticket to strange segfault bugs when you cast the result to the wrong type. And since C/C++ types are not first class, you can't even construct the casts at runtime! (Ok, maybe C++11 has some new foo_cast template, I'll admit my C++ is a bit rusty).

I simply replied to the question "how do you call a C++ method by its name from a C++ plugin".I don't see what this has to do with MOC.There is no need to build any table either. There is no need to store anything, nor to use RTTI.

If you really wanted to generate tables of data (which again, I repeat, is not needed to do this), you still wouldn't need MOC anyway. You can just use macros and potentially templates to do that.

It works fine for any symbol, including non-static class members or whatever else you've put in your binary. dlsym does not care about the type of the symbol or the calling convention to call it, that's up to you to handle.Now then, what you can argue is that this isn't a nice programming interface. It isn't, it's just how the platform does dynamic linking.

dlsym(h, "my_method")There is no need to store it, it's already in the symbol table.

If you do want to store it, there is no need to use an external preprocessor anyway.

Sorry, wrong answer. C++ method name symbols are mangled to include class name and parameters. Worse, this mangling is not standardized, it is compiler specific. In other words, that is not a method name, that is a C function name in the example you gave.

But it's even worse than just generating the symbol name. With virtual methods, you have to determine at runtime, what is the real class of the object pointer, because you need to call differently named method based on that. So, could be done with RTTI and

Yes and no. The signals and slots mechanism is still there and it's still using moc, but there's a new connection syntax available that's a lot more C++ like, allows C++11 lambdas in place of slots, and offers compile-time checking of connections that previously would just fail at run time. Won't please the purists, but it's a step in the right direction.

You can now use any C++ function as the target of a signal using the new QObject::connect() syntax. This is a huge win because with the new syntax the compiler and linker can check that the connections are valid instead missed connections just causing a run-time error.

The moc preprocessor is still required for QObject derived classes, mostly for the translation framework and also to provide support for the old signal/slot syntax which is still allowed. Qt5 doesn't require a C++11 compliant compiler, which is a good thing since there aren't yet any fully compliant compilers. I'm sure if there is a Qt6 it will require C++11 and use those features.

Some of the really cool C++11 features like move constructors aren't necessary with Qt because it's containers implement reference counted copy-on-write, so when you assign a QMap from another QMap no copy is made, and if the old QMap was an rvalue then there is never a need for the copy to be made when the new QMap is modified. One of the big improvements Qt4 made over Qt3 was to make container assignment atomic so this mechanism worked with threaded code and defensive deep copies weren't necessary anymore.

Qt5 doesn't require a C++11 compliant compiler, which is a good thing since there aren't yet any fully compliant compilers. I'm sure if there is a Qt6 it will require C++11 and use those features.

C++11 is not necessary for MOC-less signals/slots - Boost has been offering them for years with all existing compilers.

Some of the really cool C++11 features like move constructors aren't necessary with Qt because it's containers implement reference counted copy-on-write, so when you assign a QMap from another QMap no copy is made

Sure, but what about your own types? Implementing COW is much harder than implementing a move constructor. I do hope that Qt containers use move semantics for elements when available, at least?

Also, COW is not free when it's thread-safe. Those atomic increments and decrements do add up, especially on instances of types that are copied around a lot (strings are a classic example of that).

That helps. On the other hand, if you use that trick (copying pointer to actual data around), you get the overhead of an extra indirection on every field access, as well as a heap allocation for every instantiated obejct (even if it's instantiated on stack). As I understand, Qt pretty much has to do it anyway for its classes to enable binary compatibility between minor releases via the usual Pimpl idiom, but it's not necessarily desirable for user classes.

First, it's not bastardized. C++11 is the bastardization, because it results in code fragmentation. That wonderful cross platform C++11 function you write can only be targeted by C++11 compilers. Meanwhile in Qt land everything keeps working on your legacy compiler. The fact that it uses compiler macros to accomplish cross-platform cross-compiler interoperability does not lend itself to "bastardization"

MOC is not ugly, though I would prefer a C# approach of not having to separate it into a H file, but this is more a C++ thing than a Qt thing. I love the QMeta* that allows me to have introsepction at run time (again x-platform) and I can even dynamically create classes. Can C++11 do that? (Well i guess it can if it's using Qt) But they are adding C++11 syntax if you are using a C++11 compiler and want to limit your portability.

Qt signals are modeled after boost signals. I can't say what other than syntax is different (Qt begin easier to read), but signals/slots are supported in all paradigms - PyQt/PySide, QtQuick (JavaScript) and in threads. I don't think Boost has support for JS and Python. Functionally though, they are the same.

That would be impossible, given that Qt signals appeared much earlier than Boost.Signals. Indeed, I don't think Boost itself existed at that time - the effort for that began in 1998, while the first release of Qt was in 1992 (and, if I remember correctly, it had signals/slots since inception).

can't say what other than syntax is different (Qt begin easier to read),

Boost.Signals is a pure C++ solution that relies on templates and does not need any kind of preprocessor. It works out of the box on vast majority of C++ compilers, including g++ and MSVC.

Well, Boost is a C++ library. That said, you don't really need any special support for signals in JS or Python, because they already have functions as first-class types.

I think he meant, he doesn't think it's easy to create bindings for emitting Boost signals from javascript or Python, like you can do from javascript engine running in Qt app, or from PySide/PyQt application.

While this doesn't make sense for Boost alone, without context, it becomes relevant and even critical, if you have a library/framework using Boost as core signal/slot mechanism. If you do that, how easy is it to emit such signals from an interpreted language? Or, to put it other way, are Boost signals a

Well, Boost signals are just function objects. So long as whatever bridge you use to call C++ from a scripting language lets you invoke operator() on arbitrary stuff, it can emit a signal. I think Boost.Python would be able to do that, for example.

I'm sorry but I couldn't see native code in any of these. Maybe for apps that use deals with small amount of text input, simple graphics, no peripheral hardware interfacing, have no intensive background processing and are running on very good cpus then that is okay. But for anything serious, just no.
Plus all these things are designed for webapps that run in a browser. Qt is for desktop apps. Comparing them is just stupid.

I doubt it. Qt is nice but depending on what's being developed, HTML5/JavaScript can be the superior solution.

I think there are very few different cases where HTML5+JavaScript is superior. Online cloud-backed apps running in browsers are obviously one case, removing the need for separate download, and on native side there's the case where HTML+JS is the only alternative supported by all platforms where the application needs to run...

But HTML (any XML) is klunky compared to QML if you want to go the declarative route, and for "real applications" like the much-mentioned Autodesk Maya, they're not even competing becau

So, is it fully standard C++ now or do you still have to use their hokey preprocessor?

Well, for many things Qt requires reflection features not provided with C++. When/if C++ starts to provide them as part of the language, I'm sure moc will become thing of the past, and be replaced with just translation data extractor, which you can leave out if you do not care about internationalization. But for what it's worth, with the new signal-slot connect syntax it's probably possible to have meaningful programs without running moc, if that makes someone happy.

So, is it fully standard C++ now or do you still have to use their hokey preprocessor?

Qt is, and always has been fully standard C++. The "moc" program is not a preprocessor, is just a tool, more precisely, just a code generator that writes for you some files that you have to either include at the end of your ".cpp" or you have to compile and link like other hand-coded files. If you use QMake, or CMake or any other buildsystem that has some Qt support (and most do), is completely effortless.

At a first glance, you see things that might look like an extension to the language, because you see st

How exactly the magic Qt keywords like "slots" is implemented is really an implementation detail. From programmer's perspective, they are language extensions, because they introduce some new and important semantics into the language. The fact that they're handled by a separate codegen tool and stripped out of the code that's fed to the C++ compiler is irrelevant - you could just as well implement them directly in the compiler without changing their meaning, and it wouldn't magically change what they are.

I used Qt Quick briefly. It seems like you get a lot of deep powerful customization, but that comes at a cost. It eventually pissed me off so I went back to QWidget, and my productivity soared.

I would not have completed my project in a reasonable time using Qt Quick. It is not "quick". Sometimes, you just want to drop tables, check boxes, buttons, etc. on to your main window, tie the click event to a slot, and call it done. You are fine with whatever default styling and rendering that Qt and the OS decide is appropriate for the widget's click/hover/etc event.

It seems with Qt Quick, you have to specify all that nonsense. Plus, the Qt Quick editor tool felt complex and confusing. I avoided it and did everything by hand. Qt Designer for QWidgets is a drag-n-drop breeze. I even got my manager on board after he saw me using it. He is an EE, and he really likes it. He is used to spending $500 on Visual Studio Pro to what Qt Designer does better for free.

Maybe I just needed to study Qt Quick more to get past the learning curve, but I knew how to do it the widget way, and I wanted the project done.

Has anybody had success migrating their project from QWidgets to Qt Quick? Unless I see a strong compelling reason, I am sticking with QWidgets. It works really well for me.

My understanding is that the big problem with Qt Quick is the lack of all the usual widgets. There really isn't any particular reason why you shouldn't be able to define QML graphs in terms of "I want this button here and this textbox there", and them assuming the default theme etc.

If you are use to using QWidget and that is what you are comfortable with, then there is absolutely zero need for you to try and pick up Qt Quick. Qt Quick is really good at building one offs that you need for small tasks, think million little widgets here, not database editor. Qt5 is still centered very much around C++ and the people who wrote Qt are very aware that Qt Quick "is not for everyone".

You may find yourself pulling up Qt Quick for implementing a "find dialog" or a "insert criteria dialog",

Has anybody had success migrating their project from QWidgets to Qt Quick? Unless I see a strong compelling reason, I am sticking with QWidgets. It works really well for me.

For an existing project, I think the only compelling reason would be, if you want a bling-bling GUI for touch interaction. Think of flick scrolling, multi-finger zoom&pan, animated transitions. And then it would need to be a complete UI redesign.

But, in 1-2 years, I think almost all new displays even on desktop, and certainly on laptops, will be touch screens. I think this is a good time to start thinking about a full UI re-design for any application, where displaying information is important.

Often it's possible to do both. For Krita, which has been around as a QWidget application for more than ten years now, it was possible to make a Qt Quick-based version in about four months with two people: Krita Sketch, which offers almost all the functionality of Krita Desktop, but touch-enable.

As someone who's been on Slashdot since the 90s, I think you're tilting at windmills. When was the last time you saw a really good summary on Slashdot? Shitty summaries are the norm here, and they're frequently downright misleading and contradicted by the articles linked. There is NO editorial control here, just sensationalism.

Speak for yourself. Some of us have multiple monitor setups, e.g. 1 in landscape, 1 in portrait. The ability to dynamically attach/detach tabs as separate windows is very handy. IDEs and web browsers make use of this feature.

That seems like totally valid criticism to me. So you're saying Qt is equal or inferior in all respects, and uses more resources? You should blog about this, because no amount of googling turns up remotely similar results. As a matter of fact, people seem to be quite happy with Qt, and "shinyness" doesn't even get mentioned in those discussions. Or is shiny just code for "not as fugly".. ? Please elaborate.

You obviously never programmed with QT then. QT API is generally pleasant to work with in that it's well documented, consistent, and not unnecessarily complex with a decent amount of examples.

QT is a larger framework because it does quite a bit more then GTK+ and others. In a Linux environment, that ram usage is shared so you can end up using much less ram in the end with multiple programs running on the same large library. This unfortunately is less of an advantage in Windows (where you see much less GTK+

It is not is such a unreasonable thing as to assume basic knowledge of the field. This is a site predominantly amid at compsci people and largely open source/*nix people at that. Knowing what qt is or the ability to find out on your own what qt is, is not unreasonable here. If you think they should have give you a definition of qt then why not ask for a definition for C++ as well as that would be just as nonsensical in this context.

Agreed. I've never developed anything using Qt, but have a pretty good idea of what it is. Even if I'd never heard of it before, a couple of mouse clicks and 3 keystrokes (assuming I've got Google or Wikipedia bookmarked) would've yielded an answer in seconds. Given this, and the fact that most people on/. probably already have at least a vague notion of what Qt does, I don't think it is necessary to explain it every time it comes up.

It's the framework for KDE, which is the excellent, fast UI environment I use on my Linux rigs. Apparently a huge number of other projects either use it currently, or have used it in the past, including a number of well-known projects: Amazon Kindle, Google Earth, Adobe Photoshop, MythTV, Rosegarden, Skype, Virtualbox, VLC media player.

On the business software side, there's also well known applications like Autodesk Maya (2011 and above, they switched TO qt recently!), and also the Perforce client (P4V).
I'm seeing more and more of it in the internals of "big" apps like that, even if the user is unaware. I have a feeling its partly because of the LGPL side of things opening up more than anything. Although I'm pretty sure autodesk licensed it commercially.

It's the framework for KDE, which is the excellent, fast UI environment I use on my Linux rigs. Apparently a huge number of other projects either use it currently, or have used it in the past, including a number of well-known projects: Amazon Kindle, Google Earth, Adobe Photoshop, MythTV, Rosegarden, Skype, Virtualbox, VLC media player.

Hey, several of my favoruite Windows apps are in Qt (e.g. from my WinXP days: "Launchy", and current versions of TweetDeck and Calibre).

Qt-on-Windows runtime installs much like the Visual C++ runtime, and that, for me, is preferable over any app done in Java/Perl/Python, as I don't have to clutter up my system with RTEs (that are all too often supporting a single app)

He probably means that because the brain damage management at Nokia couldn't get it going on a phone that it's doomed. Android and Apple won and if you buy into the "Desktop is Dead" idiocy then you think that mobile is the only target that matters. We won't tell the fuck head that 9 out of 10 times those "Desktop is Dead" articles are viewed from a desktop. It's confusing to them. No those are real numbers. Go look at all the sites you use to decide who's winning the browser war. They may disagree on

It's mature and has all the bells and whistles. Only other alternative is WxWidgets...

What else did you have in mind ?

Here's the basic group that Qt belongs as part of:

Qt

Gtk

WxWidgets (WxWindows)

SDL

WxWidgets is public domain; and was the first (AFAIK) to do both Signals/Slots and Message Maps for inter-object comms.

Gtk was originally just MessageMaps, and now also does Signals/Slots; but it also tends to be heavily GNOME centric and rather largely ignored by GNOME in maintaining it - it moves along, but at a snails pace because they're not really paying attention to it (to my understanding from talking to someone in the GNOME community).

SDL isn't quite as feature complete as any of the others, but can get the job done.

Qt is really the only first class library in that group, and now reaches even more platforms than ever before. And with Qt embedded, it runs in many devices that you may never have thought of as having run Qt (Microwaves, TVs, Refrigerators, etc.). Qt really is to multi-platform development what Linux is to processors in that respect.

So in the sense that nothing else is really as feature complete and professional as Qt - yes, it's in its own category. But in reality there are several other major competitors - and all from the FLOSS community at that.

Small correction: wxWidgets isn't public domain. It's licensed under the wxWindows Licence which, as their page states, is like the LGPL but with a few differences.

Interesting. I hadn't looked at in in a few years (2004,2005). So they've changed their license since it use to be public domain. I was surprised at the time, but oh well. Good to see them using a nicer license though.

SDL isn't quite as feature complete as any of the others, but can get the job done.

That's... a bit of an understatement. SDL is a frame buffer, audio buffer, and input poller. For writing GUIs, it's about as feature-complete as QPainter. Sure, you can write your own GUI widget library on top of it, but that won't be pleasant for you or your users.

SDL is more suited for abstracting the platform video/audio/input APIs, and can be used nicely in conjunction with Qt, GTK+, etc.

The standard xinput mechanisms have full tablet support now. You can even use use cheap knockoff tablets now thanks to digimend [sourceforge.net] (I got one from monoprice and it's pretty great for messing around with handwriting recognition and I've discovered that image editing with a trackball + tablet is great). Unfortunately all tablets are kind of broken except in the latest release of X.org because of a bug with coordinate transformations (basically, the pointer jumps if you make pressure changes without moving becaus

Apparently it had far too little buzzword-compliance with their traditional widget-based imperative style GUI, now it's HTML/CSS/Javascript and declarative style GUI that is the "hot thing". I guess the good side is that it's like writing a web app that many developers know how to do but it has pretty much all the bad sides too, personally I find it's a giant step backwards. Or rather if I was going to do it this way I'd probably just go for HTML+JQuery and make it run in a browser against a back-end inste

And what's wrong about it? HTML5/JS is not bad because it's declarative. It's bad because HTML was never designed to lay out UI, and JS is just a quirky, horribly designed language. But do declarative UI with an expressive data binding framework, and use C++ (rather than JS) for the model, and it's beautiful.

That's true of any product release by any company. The releaser is always going to make the claim that it's better than before. It's up to you, the consumer, to look at the product and make a decision. If you want to make an informed decision you'll probably need to look at both what its promoters and its detractors have to say about it. This article is obviously about the promotion side of the product. You may find some detractors in the comments but so far they're doing a piss poor job. You'll have t

Yes, QTextEdit handles both HTML and plain text. If you want to export the current text as a full HTML document, you call toHTML(); and if you want plain text you call toPlainText(); Both methods produce a QString that has the text area contents.

Someone has probably already extended QTextEdit to make a drop-in widget that has better syntax highlighting. I know the same thing has been done for spell check.

I'm still using 4.7.4 and I intend to do so for a long time. My main reason is to keep pace with the Debian repositories (4.7 support was recently added to testing, stable still has 4.6). For the past year I've been working on an app that won't build on 4.6 b/c of new features added to 4.7, meaning support in Debian Stable was out unless you roll your own Qt. Anything I write for Qt 4.7 will probably compile fine with Qt5 (if necessary) or run under Qt5 libs so I see no reason to upgrade.