Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Is this a vector? How does it work?
C++
QHash<int, qbytearray=""> AlbumModel::roleNames() const
{
QHash<int, qbytearray=""> roles;
roles[Roles::IdRole] = "id";
roles[Roles::NameRole] = "name";
return roles;
}


What I have tried:

Is this a vector? How does it work?
C++
QHash AlbumModel::roleNames() const
{
QHash roles;
roles[Roles::IdRole] = "id";
roles[Roles::NameRole] = "name";
return roles;
}
Posted
Updated 17-Nov-20 21:26pm
v2
Comments
CPallini 18-Nov-20 2:08am    
You have also the option of reading the documentation.
Richard MacCutchan 18-Nov-20 3:26am    
See my answer below.
CPallini 18-Nov-20 4:58am    
Been there, done that, given your solution a 5.
Richard MacCutchan 18-Nov-20 5:12am    
You are too generous. :)

How many more times do you plan to ask this question? I have already given you links to the documentation where you can find the answers, please go and study it.
What type of vector is this. Or how does this work?[^]
 
Share this answer
 
Comments
CPallini 18-Nov-20 4:58am    
5.
KarstenK 18-Nov-20 8:25am    
some people ask til the get the wanted answer like children ;-)
Richard MacCutchan 18-Nov-20 8:27am    
:(
Short answer no. QHash is not Vector.
Read this document to understand vector - std::vector - cppreference.com[^]
I will refer three documents for you.
* Templates - C++ Tutorials[^] - will explain what templates in C++ is
* C++ - Default template parameter value | c++ Tutorial[^] - this will help you to understand template with default parameter
* QHash Class | Qt Core 5.15.1[^] - this will assist you to understand QHash Class.
 
Share this answer
 
It is a collection so it is sort of like a vector but not exactly. It works like this : QHash Class | Qt Core 5.15.1[^]
 
Share this answer
 
Comments
CPallini 18-Nov-20 2:07am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900