qobject

In Qt, how do I use Q_OBJECT slots and signals with multiple inheritance?

I looked through the related questions and couldn't find anything that addresses exactly what I was talking about, so let me describe. I have a class, let's say foo that needs to have its own slots and signals, but also needs to inherit from QXmlDefaultHandler (sounds rather odd, but I encountered this situation when trying to use QHttp...

Proper way to check QOject derived class type in Qt

Lets say I have a two classes: class A : public QObject {}; class B : public QObject {}; then I go QObject *a = new A(); QObject *b = new B(); now, how do I make sure that "a" is an instance of class A, and "b" is an instance of class B? currently I do something like this: if (a->inherits(A::staticMetaObject.className())) { ... ...

Add QObject in the combo box of Qt

I have a custom class I created, say MyClass. Now how to add a reference to MyClass's reference as second parameter in the combo box below: this->ui->comboBox->addItem("item-1", ); Purpose is to when item changed even is fired, i want to get that specific class instance of MyClass and process accordingly. ...

Order of QObject children (strategy question)

For one of my projects I have a tree of QObject derived objects, which utilize QObject's parent/child functionality to build the tree. This is very useful, since I make use of signals and slots, use Qt's guarded pointers and expect parent objects to delete children when they are deleted. So far so good. Unfortunately now my project req...

django dynamic Q objects in generic view

Hi, I want to be able to pass a variable caught in the URL to a Q object for a generic view. I created a generic view which is imported as my_views.view which handles things like pagination, sorting, filtering etc... I need to use Q objects because for some pages there will need some OR filters. Each page will also be filtering based o...

Get a list of all QObjects created in a Application

To get a list of all the widgets created into an application we can simply call : QApplication::allWidgets() Read the docs, and I havn't found nothing like this to get a list of all QObjects, so if an application creates stand-alone QObjects that are not QWidgets I have no such a simple function to use. Is there a method to obtain suc...

Is there a way to be notified when a property changes in a QObject?

First off, I'm using the Qt 4 libraries and C++. Is there a way to be notified (signal, event, ?) when a property (dynamic or otherwise) changes on a QObject? I can't modify the QObject class as it is part of the Qt4 library. More info about QObject here. ...

Qt: Setup my own QWidget in the right way

In Qt I'm trying to set up my own QWidget so everything should work good due to memory management and other things. But I can't seem to get it all right with pointers, heap and stack. I have my widget MyWidget that have a QList with some objects. I can't figure out how to set up everything right. You can see my code below and I have som...

Qt Object Linker Problem " undefined reverence to vtable"

This is my header: #ifndef BARELYSOCKET_H #define BARELYSOCKET_H #include <QObject> //! The First Draw of the BarelySocket! class BarelySocket: public QObject { Q_OBJECT public: BarelySocket(); public slots: void sendMessage(Message aMessage); signals: void reciveMessage(Message aMessage); private: // QVector<M...

How do I copy object in Qt?

I'm using Qt and have some real basic problems. I have created my own widget MyTest that have a variable obj. I need to set this variable obj from an object outside of the widget so that the variable is copied not just a pointer to another object. I get an error message and can't figure out how to do this basic stuff. This is the code I'...

QObject cloning

I know that Qobjects are supposed to be identities not values eg you cannot copy them and by default the copy constructor and asignment are disabled as explained in qt documentation. But is it possible to create a new Qobject from an existing one using a clone method? Would this be a logic error ? If i say QObject b; QObject a; b.clo...

Why am I able to create a copy constructor and overload the assignment operator for a QObject subclass?

I was under the impression that QObject disabled the copy constructor and assignment operator... why am I able to compile this QObject derivative containing both of these? #ifndef QVERSION_H #define QVERSION_H #include "silverlocklib_global.h" #include <QtCore> struct SILVERLOCKLIBSHARED_EXPORT QVersion : public QObject { Q_OBJECT...

Django search for strings containing spaces

I have a seach by name function, which should return the name of one person, if the search matches the first name or the last name. The problem is that if i search for strings like 'firstname lastname' it doesn't find the name that matches (guess it's because of the space between the words) . What should i do for the search to work? Also...

Django - How to transform a QuerySet to a Q object?

Is there a way to transform a QuerySet to a Q object in django? My specific motivation: I would like to subtract one QuerySet (qs_A) from another QuerySet (qs_B). The only way I can think of is by using exclude() and a Q object equivalent of qs_A. Example: def my_function(qs_A, qs_B): # Here I need to transform qs_A to a Q object ...

Q_OBJECT linker error!!

Hi, 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...

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

Hi, 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...

Should non-QObject derived classes "always" be put on the stack?

Coming from the Symbian world, I'm used to using the heap as much as possible to avoid running out of stack space, especially when handling descriptors. CBase derived classes were always dynamically allocated on the heap, since if they were not, their member variables would stay uninitialized. Does the same convention apply to QObject-de...

Why won't this compile (link) with the Q_OBJECT macro in place?

Hi, I made a prototype of a project with PyQt and made it work there, now I'm trying to convert it to C++ and am having some problems. If I don't put the Q_OBJECT macro in, it compiles and works, but if I comment it out, I get the following errors: Undefined symbols: "vtable for MapView", referenced from: MapView::~MapView()in...

Qt, CMake, Visual Studio and Q_OBJECT in cpp files

Hi, I'm developing a large project using Qt 4.6, CMake 2.8 and Visual Studio 2008 for the Windows platform. As far the build system goes, it's all standard stuff: I'm using CMake's QT4_WRAP_CPP macro to generate moc files from header files, which are then linked into the final executable in the add_executable command. Everything is wor...

Qt interfaces or abstract classes and qobject_cast()

I have a fairly complex set of C++ classes that are re-written from Java. So each class has a single inherited class, and then it also implements one or more abstract classes (or interfaces). Is it possible to use qobject_cast() to convert from a class to one of the interfaces? If I derive all interfaces from QObject, I get an error due...