Questions tagged [qhash]

QHash is a Qt template class that provides a hash-table-based dictionary

QHash provides very similar functionality to QMap. The differences are:

  • QHash provides faster lookups than QMap.
  • When iterating over a QMap, the items are always sorted by key. With QHash, the items are arbitrarily ordered.
  • The key type of a QMap must provide operator<(). The key type of a QHash must provide operator==() and a global hash function called qHash() (see qHash).

Documentation can be found here for Qt 4.8 and here for Qt 5.

68 questions
0
votes
1 answer

Qt Command Pattern QHash/QMap

I've recently implemented a command design pattern in Java with the use of: private HashMap commands; Where Component is any Java Component (JButton, JMenuItem, ...) and CommandInterface is an interface for my…
chrizbee
  • 145
  • 1
  • 13
0
votes
1 answer

QMutableHashIterator - no appropriate default constructor

I am trying to pass data into my hash named "dictionary", I thought I would use a QMutableHashIterator to iterate through the hash and add values to it, however, I keep on getting this error but I have no idea how to solve it. I have looked at other…
Kitty Burner
  • 47
  • 11
0
votes
1 answer

Data read from file takes way more memory than file size

I've written some data into a file the following way: result = new QHash, QVector >; QFile resfile("result.txt"); resfile.open(QIODevice::WriteOnly | QIODevice::Append); QDataStream out(&resfile); while(condition) { QString…
0
votes
1 answer

How to serialize a QHash and a QMap in a single file?

I have a QHash and a seperate QMap. I can serialize them alone. But I would like to serilize them in a single file: QMap myMap; QHash myHash; // .. fill: both have 4 (key,value) pairs. // write here QDataStream out…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
0
votes
3 answers

Serializing QHash with own Class?

I have a QHash , whereas MyClass is just a collection of some QString quint8 values with getters and setters. MyClass also has a QDataStream &operator<<(QDataStream &ds, const MyClass &obj) overwritten, there. To serialize…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
0
votes
1 answer

QHashIterator in c++

I developed a game in C++, and want to make sure everything is properly done. Is it a good solution to use a QHashIterator to check which item in the list has the lowest value (F-cost for pathfinding). Snippet from my code: while(!pathFound){…
Tim Dirks
  • 439
  • 1
  • 6
  • 17
0
votes
1 answer

Building a QHash with QStringList in C++

In C++ I am trying to build a specialized QHash like this: QHash myhash; Such that I can store this type of data: QHash key QStringList values ---------- ------------------ A 1 2 3 B …
panofish
  • 7,578
  • 13
  • 55
  • 96
0
votes
1 answer

Qhash of Qhash reports error

I have written a function with qhash of qhash, which is shown below: void scanOccurenceOnAllSequence(QString motif, QString chkMotif, qint32 offset, QString cell, QHash > > *motifByCell2seq,…
ybzhao
  • 69
  • 9
0
votes
1 answer

How to store Qfile in Qhash

I want to write the data to many different files randomly, So I store the QFile * to Qhash, But it seams not work. and there is a report QObject::connect: No such signal QObject::aboutToClose() in…
ybzhao
  • 69
  • 9
0
votes
0 answers

QHash multiple keys but search each one not fuse each other

I am trying find out solution according to other answer, the following link explained how to merge two key like one key with QHash. Implementing a QHash-like lookup with multiple keys But i would want to also get value each of key, for…
Murat
  • 1
  • 2
0
votes
1 answer

Using QGraphicsItem as key for QHash

Before I embark into using this datatype and as I am a beginner in Qt, is it possible to use QGraphicsItem as key of QHash? It seems legal to declare something like: QHash hashName; So I guess it is something…
Francesco
  • 481
  • 2
  • 4
  • 16
0
votes
2 answers

QMultiHash and values of class pointers

Consider the following small code: class Person { public: QString name; int age; }; int main() { QMultiHash personHash; Person* p1 = new Person; p1->age = 24; p1->name = "X"; personHash.insert(p1->age,p1); …
Ameen
  • 1,857
  • 2
  • 23
  • 30
0
votes
1 answer

Improving performance using QHash and QList

I'm using these classes: QHash: rapresenting all the objects of the scene (cannot modify this class) QList: rapresenting all the objects selected. It contains IDs (saved as int) //DrawSelectedObjects(){ QHash&…
Tcz
  • 661
  • 5
  • 18
0
votes
1 answer

QHash cannot convert parameter 1 from 'class QHash::const_iterator' to '::iterator'

I have a qhash defined with key value pair as QDomElement. as given below. I am trying to update the hash by using const_iterator. But while doing so below error is thrown, how to resolve the same:- error C2664: 'erase' : cannot convert parameter 1…
Priyanka Bhatia
  • 97
  • 2
  • 10
0
votes
1 answer

QPointer to QHash

Is it possible to use QPointer with QHash? QPointer> > pHash;
user635818
  • 99
  • 2
  • 9