PDA

View Full Version : Reg: Qt Metatypes and their use in Plugins



qtnewbi3
8th August 2011, 19:57
Hi,

I am trying to create a plugin from a widget that can be used through qt designer. The widget has a slot which receives a QList<QString>Names as one of the conditions. I have used typedef QList <QString > Names at the start of the widget header file and used qregistermetatype in the .cpp of the widget and it compiles fine but when I try to run qt designer with the plugin added, it doesnt open. Is there some sort of setting that I would have to change in the .cpp , .hpp files of the widget or the plugin.cpp /hpp files to allow for this to work with Qt Designer..,.

wysota
8th August 2011, 20:13
Why don't you just use QStringList instead?

qtnewbi3
8th August 2011, 22:45
Hi Wyotsa,

I was actually looking at old threads , and I was using QStringList but I was getting empty lists in this attempt and the reason I was taking this path was because the next thing I want to do is pass List of QImages as well.

wysota
9th August 2011, 07:33
If you were getting empty lists with QStringList, why do you expect to get populated lists with QList<QString>? It seems your code is flawed somewhere. As for the original issue, you're crashing Designer with your plugin. Debug it and trace the crash, the plugin is probably incorrectly implemented (some dangling pointer somewhere?) regardless of the type you use.

qtnewbi3
9th August 2011, 15:16
Yeah, my code was a little buggy with regards to QStringList and I was able to fix it and get the plugin up and running but now I still have the issue of using QList with QImages could you please point me in the right direction with regards to Metatypes, i have never used it before and the documentation was also unclear to me. I tried some stuff and was getting template errors. Is there an example which it was used in for Qt or are there any tutorials regarding the metatypes.

wysota
9th August 2011, 15:48
Ok, but what exactly do you want to do with QList<QImage>? You want the user to be able to select a number of images from within Designer and store those pictures in the ui file along the form info? If so, then in simple words this is not possible, at least not directly. Or do you want something else?

qtnewbi3
9th August 2011, 22:02
Wyotsa,

No thats not what I wanted , I was able to figure out how to send the QList <QImage> as a signal. I just wanted to send a list of images on the fly without storing them on the drive to another plugin and connect these 2 plugins. Anyway thanks for your help...

Cheers

wysota
10th August 2011, 09:20
That's not a problem, just Q_DECLARE_METATYPE(QList<QImage>) and qRegisterMetaType<QList<QImage> >("QList<QImage>")