Disclaimer: I love C++11! It’s the best thing that happened to C++ since I’m using it (mid-90’s). I’ve been hoping for lambda‘s in C++ since I discovered and started using Lisp. Elisions and move semantics – together with unique and shared pointers – pretty much free you from thinking about memory management! It’s just amazing! Check out “Going Native” talks on YouTube, incl. amazing talks by the likes of Stroustrup, Sutter, Lavavej, et al.
If you don’t want to read my rant, here’s the point – function objects are objects – they can get copied, unless you specify otherwise, so beware that you’re working on a copy, or pass std::ref.
Provided how much you can do with Qt Widgets, or Qt in general, it’s no surprise that such “specialized” function is not present (the QApplication::activeWindow() does not make it, as the window might not be active).
QWidgetList widgets = qApp->topLevelWidgets();
for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i)
if ((*i)->objectName() == "MainWindow")
return (QMainWindow*) (*i);
If, for whatever reason, you changed the “objectName” property of the main window, update the above if with this name.
This post is more of a mocking than serious advice, provided that a) STL includes <fstream> header with std::ifstream and std::ofstream classes, that do the same without any additional effort, and b) mixing templates and libC is just plain weird in my book. Continue reading →
OpenVPN’s installer allows for command-line based (silent) installation, but this feature is not actually documented explicitly anywhere. Here’s all I could find – hope this list will help someone in the same situation I was in.
This has been haunting me for quite some time. When building Qt app for Windows, the QImage::save() function did not work for JPEG for deployed applications, while it did work if Qt SDK was installed on the machine. Continue reading →