Questions tagged [qvariant]

QVariant is a data type in Qt library, that acts as a "container" for most of the common Qt data types.

QVariant can contain most of the basic Qt data types, and perform easy conversions between them. QVariant can also contain tree-like structures, which is shown in this small example:

//Creating a list of QVariants.
QVariantList myList;
//Creating a single QVariant variable
QVariant var;
//Populating the list with different types
myList << "Hello, world!";
myList << 15;
myList << 0x0A;
//After the following assignment, the variable will hold the list.
var = myList;

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

181 questions
2
votes
0 answers

Make QGenericArgument/Q_ARG from QVariant

I wrote an interface for systemd-timedated: #include #include Q_DECLARE_LOGGING_CATEGORY(timeDateInterfaceCategory) #define TIMEDATE_DBUS_SERVICE "org.freedesktop.timedate1" #define TIMEDATE_DBUS_PATH…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
2
votes
1 answer

Problem with QVariant/QTreeWidgetItem/iterator on qt4.4.3

In my qt app I have this object, filled before setting up my QTreeWidget's content: QList items; I fill the QList by this way: QVariant qv; // I need this for "attaching" to the item my linuxPackage…
JuanDeLosMuertos
  • 4,532
  • 15
  • 55
  • 87
2
votes
2 answers

Can I conveniently converty QVariant back to QList?

It is possible to convert QList to QVariant provided you declare your type as q meta type using this macro: Q_DECLARE_METATYPE(MyType); After that, the conversion is even implicit: QList list; QVariant variant =…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
2
votes
2 answers

QVariant and qRegisterMetaType question

I have a class Pkg and I need to use it under form of QVariant. At the end of my Pkg.h I have: Q_DECLARE_METATYPE(Pkg) and this does not give compile errors, but in my main.cpp I have to do: qRegisterMetaType("Pkg"); and this does not give…
JuanDeLosMuertos
  • 4,532
  • 15
  • 55
  • 87
2
votes
2 answers

Is it possible to store a QPushButton in a QVariant?

I'd like to know if it's possible to store a QPushButton in a QVariant. More precisely, I am trying to use it in a QStandardItemModel with the function setData. Here's what I want to do : QPushButton* button = new…
IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
2
votes
1 answer

How to extract a two-dimensional array of single precision floats from a QVariant?

I am using the ThermoVision SDK in Qt to communicate with a FLIR A320 IR Camera. The ThermoVision SDK is ActiveX based. I am having trouble retrieving an image from the camera with the GetImage method, which according to the manual can be used in…
Fré
  • 21
  • 1
2
votes
1 answer

How to declare Qt::PenStyle in Qt5?

I am migrating a project from Qt 4.x to 5, and there is a class that contains an attribute that goes: Qt::PenStyle penStyle; and its respective get function: Qt::PenStyle getPenStyle() {return penStyle;} I get a compilation error saying that…
Victor
  • 907
  • 2
  • 17
  • 42
2
votes
1 answer

Qt 4.8.5 QVariant unresolved external symbol Visual Studio 2012

I am trying to compile my first Qt project in VS 2012. I am using Qt 4.8.5 opensource. I have managed to get everything compiled and I have installed the VS2012 QT add-ins. There is apparently no add-in for QT4 only QT5. I had a very basic app…
jasonlg3d
  • 484
  • 2
  • 7
  • 18
2
votes
0 answers

Uniqueidentifier fields of MS SQL table are empty when retriving them using QSqlQuery and QT 4.8.4

I have the MS SQL Server 9.0.4035 on Windows machine. I'm connecting to it using stable freetds 0.91 and unixODBC 2.2 on my OpenSUSE 12.3. Here is the confs: freetds.conf: ... [egServer70K] host = 192.168.16.37 instance = [my_instance] port =…
Valentin T.
  • 519
  • 3
  • 12
2
votes
1 answer

BlackBerry10 Cascades: How to convert QObject to QVariant?

I have a list of QObjects* and want to add them to my DataModel. But the datamodel needs a QVariant instead of QObject. Is is possible to convert QObjects to QVariant?
DevCoder
  • 111
  • 1
  • 3
  • 7
2
votes
1 answer

Convert QVariant back to dict in Python

I've saved dict with QSetting, and when I load it i get QVariant >>dict {u'key1': u'val1', u'key2': u'val2',....} ... >>loadedDict How to convert it back to dict so I can use it like this…
Aleksandar
  • 3,541
  • 4
  • 34
  • 57
2
votes
3 answers

Is there a possibility to automatically convert QVariants to Python objects?

PyQt 4.5.4, Python 2.6.2 Since version 4.5.2 PyQt is able to accept any Python objects where formerly only QVariants were allowed. This leads to some problems: >>> itemModel.data(index, Qt.EditRole) >>>…
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
2
votes
1 answer

PyQt: How do I find tuples using QComboBox::findData()?

I can't get QComboBox::findData to work properly in my PyQt application. It seems as if PyQt doesn't compare QVariant's with Python tuples properly, causing Qt not to find my tuples. Example follows: import sip sip.setapi('QVariant', 2) from PyQt4…
Macke
  • 24,812
  • 7
  • 82
  • 118
2
votes
2 answers

How to access the array that is value of a QVariantMap?

I have a QVariantMap whose key is a string and value is an array(of ints or strings) How do I get the individual elements of the array? map["key"] has a method toList(). Can I apply that to arrays?
user1065969
  • 589
  • 4
  • 10
  • 19
2
votes
1 answer

what is the format for saving a qml QVariantList in qml file so it can be bindable in qml when loading the file?

i am doing an application and i need to save the QVariantList list in a qml file so i can load it in qml every time i start the application to make it more clear i read qpoints from qml and store them in a qvariantlist in c++ so the next step is to…
ahmed
  • 41
  • 3