c++,qt,inheritance,qobject,moc
Assume that we have a class Test declared as: class Test : public Foo, public QObject { Q_OBJECT [..] }; If you take a look at the moc_test.cpp file that the moc tool has generated, you will see something like: [..] const QMetaObject Command::staticMetaObject = { { &Foo::staticMetaObject, qt_meta_stringdata_Command, qt_meta_data_Command,...
c++,qt,qtquick2,qobject,qtquickcontrols
Q: but I'm after the compile time checking that casting offers. qobject_cast does not offer any compilation-time checking. It is all runtime and dynamic, thus this request is not plausible. The context property is fine, or you could also get the class name with QMetaObject. Then, you could build...
c++,qt,qtcore,qobject,qt-signals
This is very ismple. You would use Qt signal slot mechanism for this. You need to connect the button's clicked signal to your update handler slot for the database. #include <QObject> #include <QPushButton> ... class UpdateHandler : public QObject { Q_OBJECT public: explicit UpdateHandler(QObject *parent) : QObject(parent) { connect(&m_pushButton, SIGNAL(clicked(bool)),...
The problem is in this function: void test_cast(QObject *returnedObject) { QTimer *timer = new QTimer; timer->setInterval(500); returnedObject = timer; //<-- changes the returnObject } You actually do not change the obj pointer passed to the test_cast function, but modify it's copy (returnedObject). As a result, the obj pointer in the...
c++,qt,qmake,qobject,qt-signals
Found the problem...I was building a Qt5.5 project with qmake version 4...
If the property doesn't exist, the QObject::property method returns an invalid variant. This is documented. Thus: QVariant filePath = activeWindow->property("filePath"); if (filePath.isValid()) { ... } Side note: comparing anything to true is either completely superfluous, or a sign of broken design somewhere. You should not have ... == true nor...
c++,qt,polymorphism,swap,qobject
You should not be passing MainWindow1 and MainWindow2 pointers to swap like below. MainWindow1* w1 = new MainWindow1(); MainWindow2* w2 = new MainWindow2(); swap(&w1, &w2); If swap could happen in this case, MainWindow1 pointer would point to a MainWindow2 object, which is not right. You have to pass MainWindow pointers...
For exposing to QML lists of QObject-derived types, one should use QQmlListProperty rather than QList<T> as the property type MyClass.h: Q_PROPERTY (QQmlListProperty<MySubClass> objectList READ getMySubClassList NOTIFY objectListChanged) public: QQmlListProperty<MySubClass> getMySubClassList() { return QQmlListProperty<MySubClass>(this, 0, &MyClass::countMySubClassList, &MyClass::atMySubClassList); } static int countMySubClassList(QQmlListProperty<MySubClass> *property) { MyClass *m =...
The file dialog appears first before main window, and I don't know why. The reason why is because the window->show() command is not entirely synchronous -- that is, when you call window->show(), it posts some events into the event loop's event-queue, so that they can be acted on during...
c++,qt,qtcore,qobject,qt-signals
There can be several reasons for the issue in general: You do not inherit QObject. You do not have the Q_OBJECT macro in your class. You do not define the method as slot in your header file where the class is declared. Your issue is the first which can be...
It can be done when you're in a member function of a class inheriting from QObject. And when you're not in scope of an object inheriting from QObject, you should use the object instance and not scoping. So for example: class MyClass : public QObject { ... void myMemberFunction() {...
c++,qt,opengl,qobject,qglwidget
You could delete the Mesh object explicitly in the destructor of your QGLWidget derived class, because everything you put in there would be executed before ~QGLWidget() itself (and before ~QObject() which is responsible for the deletion of child objects). Or you can make the object a non-pointer member, or wrap...
Find Viber's installation folder (C:\Users\<username>\AppData\Local\Viber on Windows 8), navigate to the folder with the name of the latest downloaded version (5.1.1.15 in my case), and run ViberSetup.exe. This should update it to the latest version, keeping your data and resolving the issue.
c++,qt,signals-slots,qthread,qobject
Thanks for the input. I solved it by having a singleton that has a flag that the processing loop in my worker object in the QThread reads each loop iteration. It is protected by a QReadWrite lock. int UdpThreadController::killUdpThread(int frameType) { #if SINGLETON_CAMERA_UDP_DEBUG qDebug() << "Killing Thread! Frame type is:...
c++,qt,qobject,qtsql,qsqlquery
/usr/include/qt4/QtCore/qabstractitemmodel.h:360:5: error: ‘QAbstractTableModel::QAbstractTableModel(const QAbstractTableModel&)’ is private That error message means that you are trying to copy a QObject which does not quite have the "value" semantics, but more like "identity". QObjects are inherently not copyable. The reason is that what would you do with the parent/child hierarchy in such...
c++,qt,qtcore,qobject,qt-signals
.\PBSPPTimeDelayServer.cpp(234) : error C3861: 'sig_tickExpicit': identifier not found and void sig_tickExplicit(const quint64 nNT); Basically, try to search for one of them and you will not find the other. That usually means, you have made a typo. I think what you meant to write is this (note the missing character...
Warning: Deleting a QObject while pending events are waiting to be delivered can cause a crash. You must not delete the QObject directly if it exists in a different thread than the one currently executing. You're focussing on the first statement of that sentence and ignoring the second. This...