qobject

How to bind C++ property to QML property?

寵の児 提交于 2020-05-12 20:01:23
问题 So I know how to bind QML property to C++ property, so when C++ one calls notify signal, QML updates the view. Is there any way to make C++ property update when user changes something using UI? For example, I have a Combobox, and I want some C++ property to be updated when user changes value of combobox. EDIT: By C++ properties I mean Q_PROPERTY macro in QObject -derived classes. 回答1: To bind a property from an object you didn't create in QML (or was created in another context), you have to

Repeating Q_DISABLE_COPY in QObject derived classes

半世苍凉 提交于 2020-01-11 04:28:08
问题 In Qt there is a macro that allows declaring private copy constructurs and assignment operators for classes: http://qt-project.org/doc/qt-5.0/qtcore/qobject.html#Q_DISABLE_COPY It is said that this macro should be used for all QObject (especially QWidget) derived classes. I understand how this works and why it is useful. What I do not understand: Is there any reason to repeat Q_DISABLE_COPY in my QObject derived classes while QObject already contains Q_DISABLE_COPY and through this

Q_OBJECT linker error!

被刻印的时光 ゝ 提交于 2020-01-10 18:20:21
问题 I am receiving the following linker error when I build my application. HIMyClass.obj:: error: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CHIMyClass::metaObject(void)const " (?metaObject@CHIMyClass@@UBEPBUQMetaObject@@XZ) File not found : HIMyClass.obj HIMyClass.obj:: error: unresolved external symbol "public: virtual void * __thiscall CHIMyClass::qt_metacast(char const *)" (?qt_metacast@CHIMyClass@@UAEPAXPBD@Z) File not found : HIMyClass.obj HIMyClass

Convert a QStandardItemModel to a QVariant

吃可爱长大的小学妹 提交于 2020-01-05 08:08:46
问题 I'm trying to send a QStandardItemModel-derived object to PythonQt, but I'm a little confused on how it needs to be sent. When I was using boost::python I had several controls like boost::noncopyable to ensure I wasn't recreating this object, but sharing it with python. I also had constructs to provide a boost shared pointer to python from inside python. class Scene : public boost::enable_shared_from_this<Scene>, public QStandardItemModel In PythonQt, however, I'm not sure what's available.

Qt - iterating through QRadioButtons

女生的网名这么多〃 提交于 2020-01-04 04:12:10
问题 I have a group project for school that I am working on. A member of my group has created a window that has ~75 radio buttons. I want to force all of them to be "clear" or "unchecked" on a button press. Does anyone know a good way to go about doing this? I have been looking into QObjectList but I can't simply do QObjectList *children = new QObjectList(ui->groupBox->children()); and loop them using a for loop as QObjectList does not appear to have a next method.. I have also tried to do

QT: Is it a good idea to base my domain objects on QObject?

旧巷老猫 提交于 2020-01-03 07:30:11
问题 I'm reasonably new to using the QT framework in combination with C++. I was wondering: Is it a good idea to base my domain classes on QObject? Or should I only do this for classes higher up in the hierarchy? (closer to the user interface level). The QT documentation isn't clear on this: Taken from the QT documentation: The meta-object system is a C++ extension that makes the language better suited to true component GUI programming. Obviously I want to build my application in a nice well

QT: Is it a good idea to base my domain objects on QObject?

吃可爱长大的小学妹 提交于 2020-01-03 07:30:03
问题 I'm reasonably new to using the QT framework in combination with C++. I was wondering: Is it a good idea to base my domain classes on QObject? Or should I only do this for classes higher up in the hierarchy? (closer to the user interface level). The QT documentation isn't clear on this: Taken from the QT documentation: The meta-object system is a C++ extension that makes the language better suited to true component GUI programming. Obviously I want to build my application in a nice well

Running into issues with QVariantLists and QLists of custom QObjects

◇◆丶佛笑我妖孽 提交于 2019-12-25 03:37:25
问题 I'm hoping to get some help with a snag I've run into on a personal project. Essentially I have a custom QObject inheritor that contains its own various elements of data, and another custom QObject that I would like to have some collection element of multiple instances of the other custom QObject. I've tried various ways of implementing this and thus far I've had no real success, the closest being with a QVariantList. The following snippets are from an example I wrote to recreate the issue,

How to properly delete and terminate QThread

会有一股神秘感。 提交于 2019-12-23 21:10:40
问题 I have got a subclass MyClass which inherits from QThread . I create it like this with a parent to the MainWindow instance (this): mMyClass = new MyClass("some_value", 1, 5L, this); My understanding of how Qt deals with object deletion is that every QObject , which has a parent gets deleted when the parent gets deleted. If my program does finish I get a warning QThread: Destroyed while thread is still running How can I fix this one up? I tried it with the following code in the deconstructor

Qt support for C++0x enum class

冷暖自知 提交于 2019-12-23 18:34:28
问题 Using Q_ENUMS I can now "register" with Qt an enum declared inside a class that inherists from QObject . This gives me a few cool reflection features for the enum . I'm also really enjoying the type-safe enum class introduced in C++0x. I'm wondering if you know of any announcement made by Qt developers of plans for support for the enum class . This question vaguely asks about Qt support of C++0x features in general. I'm asking specifically about enum class . I realize that since Qt is cross