Qt get children from layout
The layout does not “inject” itself in the parent-child tree, so the widgets stay (direct) children of their parent widget. You could use QLayout::count() and QLayout::itemAt() instead.
The layout does not “inject” itself in the parent-child tree, so the widgets stay (direct) children of their parent widget. You could use QLayout::count() and QLayout::itemAt() instead.
The error message indicates that you have two conflicting metaclasses somewhere in your hierarchy. You need to examine each of your classes and the QT classes to figure out where the conflict is. Here’s some simple example code that sets up the same situation: class MetaA(type): pass class MetaB(type): pass class A: __metaclass__ = MetaA … Read more
Here’s how I do it… add a file called resources.rc to your project with the contents: IDI_ICON1 ICON DISCARDABLE “res/app.ico” #include <windows.h> #include “version.h” VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION PRODUCTVERSION VER_PRODUCTVERSION BEGIN BLOCK “StringFileInfo” BEGIN BLOCK “040904E4” BEGIN VALUE “CompanyName”, VER_COMPANYNAME_STR VALUE “FileDescription”, VER_FILEDESCRIPTION_STR VALUE “FileVersion”, VER_FILEVERSION_STR VALUE “InternalName”, VER_INTERNALNAME_STR VALUE “LegalCopyright”, VER_LEGALCOPYRIGHT_STR VALUE “LegalTrademarks1”, VER_LEGALTRADEMARKS1_STR … Read more
It depends. From the documentation: When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call. When this happens, the signals and slots mechanism is totally independent of any GUI event loop. Execution of the code following the emit statement will occur once all slots have … Read more
This is a subtle bug (and probably partly at least a compiler bug) that I’ve seen before. Since QWidget has a virtual destructor, the compiler needs a vtable for your class. But your class doesn’t have any virtual functions, so it didn’t build one for your Communicate class. Add a virtual ~Communicate() {}; to your … Read more
QDataStream handles a variety of C++ and Qt data types. The complete list is available at http://doc.qt.io/qt-4.8/datastreamformat.html. We can also add support for our own custom types by overloading the << and >> operators. Here’s the definition of a custom data type that can be used with QDataStream: class Painting { public: Painting() { myYear … Read more
Use a QFileInfo to strip out the path (if any): QFileInfo fileInfo(f.fileName()); QString filename(fileInfo.fileName());
Qt Creator (source) has this functionality, it’s trivial to copy it: void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn) { const QFileInfo fileInfo(pathIn); // Mac, Windows support folder or file. if (HostOsInfo::isWindowsHost()) { const FileName explorer = Environment::systemEnvironment().searchInPath(QLatin1String(“explorer.exe”)); if (explorer.isEmpty()) { QMessageBox::warning(parent, QApplication::translate(“Core::Internal”, “Launching Windows Explorer Failed”), QApplication::translate(“Core::Internal”, “Could not find explorer.exe in path to launch Windows … Read more
Windows does not really support dual mode applications. To see console output you need to create a console application CONFIG += console However, if you double click on the program to start the GUI mode version then you will get a console window appearing, which is probably not what you want. To prevent the console … Read more
QProcess process; process.start(“gedit”, QStringList() << docPath); the same as above QProcess process; process.start(“gedit”, QStringList() << “/home/oDx/Documents/a.txt”); Also, read this.