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
1
vote
1 answer

Qt SQLITE Query QVariant Invalid

i'm reading in text values from 2 lineedit widgets and using the data from those to act as a log in system but i'm unable because the program is currently only checking if the Username is in the SQLITE database, i'm unsure why. My connection is done…
Root0x
  • 113
  • 1
  • 2
  • 12
1
vote
2 answers

Qt DBus property convert to map

I need to get a DBus interface's property, so I did interface.property(name). That returns a QVariant, but the map that a QVariant can return is only QMap, whereas I need QMap. What should I do?
user2563892
  • 553
  • 1
  • 7
  • 16
1
vote
0 answers

Snapping in grid using qt

I have implemented grid in graphicsView using drawBackgroud method. Now I also want to add snap to the grid. By snap I mean that with mouse, you can't have point other than grid points. My code to grid drawn is as follows: void…
user3859872
  • 777
  • 2
  • 9
  • 16
1
vote
1 answer

MinGW calling template from template

I have a very simple function, that will just return the value of a QVariant. It's a part of a class to return the value of the private QVariant data: template QVariantReference::operator T() const { return…
Felix
  • 6,885
  • 1
  • 29
  • 54
1
vote
1 answer

Parsing a 2D QVariantMap

Using QJson to parse this data: "ShelveId": { "0": { "BeBoardId": { "0": { "connectionId": "board0", .... followed by more data I'd like to traverse this table quicker than doing this. All maps are QVariantMaps: map_BeBoardId =…
fiz
  • 906
  • 3
  • 14
  • 38
1
vote
3 answers

Modify member variable of object held in QVariant

I have a QVariantList containing objects of different classes. I need to modify a member variable of one object held in the list. My code runs, but the object is not changing (looks like a copy of the object is being changed). Here is sample code…
TSG
  • 4,242
  • 9
  • 61
  • 121
1
vote
1 answer

qvariant_cast with custom type

I have this class, register it to use as QVariant class MyTimeLine { public: MyTimeLine(double kStart = 0, double kEnd = 1); void paint(QPainter *painter, const QRect &rect, const QPalette &palette)const; private: double…
user3510417
  • 13
  • 1
  • 3
1
vote
1 answer

no match for 'operator[]' (operand types are 'QVariant' and 'const char [2]') QVariant/QVariantMap

Im trying to make the start of a wrapper class for json in qt 5.1 and i'm working on a function which which will check if the var inputted is a QVariantMap or just a QVariant and everything works well till i go the second level of the muli dimen…
TheMan68
  • 1,429
  • 6
  • 26
  • 48
1
vote
3 answers

Iterating over a QVariant that is a QList?

I'm using QObject's dynamic property to store information to be used in a Slot that can access said property. The sender is a QState with: myQState->setProperty("key", QList(0, 1, 2)); I would like to convert the stored QVariant back to a QList…
handle
  • 5,859
  • 3
  • 54
  • 82
1
vote
1 answer

How to use VARIANT* with dynamicCall?

I'm trying to use a COM object and i'm having problem with the parameter type VARIANT*. I can use the functions of the COM object just fine, except when they have a parameter of this type. The doc generated by generateDocumentation is : QVariantList…
Tuirenen
  • 61
  • 1
  • 9
1
vote
1 answer

Build QVariant list from non-ordered data

I have this set of data: [ step:-1, name:"BaseName1", value:v1 ] [ step:-1, name:"BaseName2", value:v2 ] [ step:2, name:"ParamName3", value:v3 ] [ step:2, name:"ParamName4", value:v4 ] [ step:0, name:"ParamName5", value:v5 ] [ step:0, …
Gui13
  • 12,993
  • 17
  • 57
  • 104
1
vote
1 answer

Derives from QSettings and store QIcon

I tried to store QIcon using class, which derives from QSettings as follows: setValue("fancy_icon", QIcon::fromTheme("document-new")); but I've got an error: QVariant::save: unable to save type 69. And it doesn't work. Surprisingly if I just…
Dejwi
  • 4,393
  • 12
  • 45
  • 74
1
vote
1 answer

How to make a class in Qt both scriptable and serializable?

I'm trying to write a class with two basic characteristics: It needs to be scriptable - the class contains a number of properties and methods decorated with Q_INVOKABLE that are exposed to scripts. It needs to be serializable so that it can be…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
1
vote
1 answer

How deserialize the output from a QVariant without Qt

How Can I deserialize the output QVariant to std::string without using QT. by reqs, My program could not include a Qt. QVariant.toString().toStdString(); Example. file.ini (write with…
Agus
  • 1,604
  • 2
  • 23
  • 48
0
votes
1 answer

Qt, QStandarItemModel: Delegation items on custom QComboBox filling its contents from instantiator of model

I need to implement a table in Qt that shows a QComboBox on each row on a particular column. Based on this question: QStandardItem + QComboBox I succesfully managed to create a QItemDelegate. In that example the QComboBox contents are defined…
Fracu
  • 835
  • 1
  • 13
  • 28