Pointer to an element in QListQt: Storing a custom object in a collection by valueSplitting QList into chunks, pointers or references?Can two threads read from the same QList at the same time?How to make QList<Type*> work with indexOf() and custom operator==()?QVariant to QList with unkown list template parameterC++ - pointers in a QListNested QHash Not SavingQtConcurrent::map and list of pointersHow would a QList containing pointers behave when passed by valueQHash removal of specified position till the end of QHash and update the QList accordingly
Is it inappropriate for a student to attend their mentor's dissertation defense?
Could the museum Saturn V's be refitted for one more flight?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
What does “the session was packed” mean in this context?
Watching something be piped to a file live with tail
Can compressed videos be decoded back to their uncompresed original format?
Personal Teleportation: From Rags to Riches
Do UK voters know if their MP will be the Speaker of the House?
What killed these X2 caps?
Forgetting the musical notes while performing in concert
Why can't we play rap on piano?
How do I deal with an unproductive colleague in a small company?
How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)
What exploit Are these user agents trying to use?
Is it acceptable for a professor to tell male students to not think that they are smarter than female students?
Is "remove commented out code" correct English?
How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
What does the expression "A Mann!" means
Ambiguity in the definition of entropy
Venezuelan girlfriend wants to travel the USA to be with me. What is the process?
Why is consensus so controversial in Britain?
GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?
Mathematica command that allows it to read my intentions
Pointer to an element in QList
Qt: Storing a custom object in a collection by valueSplitting QList into chunks, pointers or references?Can two threads read from the same QList at the same time?How to make QList<Type*> work with indexOf() and custom operator==()?QVariant to QList with unkown list template parameterC++ - pointers in a QListNested QHash Not SavingQtConcurrent::map and list of pointersHow would a QList containing pointers behave when passed by valueQHash removal of specified position till the end of QHash and update the QList accordingly
I have a list of lists container with this type:
QList< QList<UAVObject *> > objects;
For some reason I would like to access one of the internal lists quickly. Can I store a pointer to an internal list? For example:
QList<UAVObject *>& ref = objects[0];
QList<UAVObject *>* pt = &ref;
Will the value of pt
still be valid across different function calls and original objects
manipulations? Let's assume that the objects
list will only be added to and never removed from.
qt qt5
add a comment |
I have a list of lists container with this type:
QList< QList<UAVObject *> > objects;
For some reason I would like to access one of the internal lists quickly. Can I store a pointer to an internal list? For example:
QList<UAVObject *>& ref = objects[0];
QList<UAVObject *>* pt = &ref;
Will the value of pt
still be valid across different function calls and original objects
manipulations? Let's assume that the objects
list will only be added to and never removed from.
qt qt5
add a comment |
I have a list of lists container with this type:
QList< QList<UAVObject *> > objects;
For some reason I would like to access one of the internal lists quickly. Can I store a pointer to an internal list? For example:
QList<UAVObject *>& ref = objects[0];
QList<UAVObject *>* pt = &ref;
Will the value of pt
still be valid across different function calls and original objects
manipulations? Let's assume that the objects
list will only be added to and never removed from.
qt qt5
I have a list of lists container with this type:
QList< QList<UAVObject *> > objects;
For some reason I would like to access one of the internal lists quickly. Can I store a pointer to an internal list? For example:
QList<UAVObject *>& ref = objects[0];
QList<UAVObject *>* pt = &ref;
Will the value of pt
still be valid across different function calls and original objects
manipulations? Let's assume that the objects
list will only be added to and never removed from.
qt qt5
qt qt5
asked Mar 8 at 22:38
ilya1725ilya1725
1,85432441
1,85432441
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
QList
is not based on a STL container and has nothing to do with std::list
.
The invalidation rules specified for the STL containers are not applicable.
According to the Qt documentation (and my understanding), it uses an array of pointers to the items, unless the item is not larger than a void*
and declared as movable (with Q_MOVABLE_TYPE).
In that case, the item is directly stored in the array and the reference will become invalid when your list will grow (the array of pointers will be reallocated).
Ah, that's why they can implement[]
access in O(1).
– ilya1725
Mar 9 at 1:31
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071969%2fpointer-to-an-element-in-qlist%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
QList
is not based on a STL container and has nothing to do with std::list
.
The invalidation rules specified for the STL containers are not applicable.
According to the Qt documentation (and my understanding), it uses an array of pointers to the items, unless the item is not larger than a void*
and declared as movable (with Q_MOVABLE_TYPE).
In that case, the item is directly stored in the array and the reference will become invalid when your list will grow (the array of pointers will be reallocated).
Ah, that's why they can implement[]
access in O(1).
– ilya1725
Mar 9 at 1:31
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
add a comment |
QList
is not based on a STL container and has nothing to do with std::list
.
The invalidation rules specified for the STL containers are not applicable.
According to the Qt documentation (and my understanding), it uses an array of pointers to the items, unless the item is not larger than a void*
and declared as movable (with Q_MOVABLE_TYPE).
In that case, the item is directly stored in the array and the reference will become invalid when your list will grow (the array of pointers will be reallocated).
Ah, that's why they can implement[]
access in O(1).
– ilya1725
Mar 9 at 1:31
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
add a comment |
QList
is not based on a STL container and has nothing to do with std::list
.
The invalidation rules specified for the STL containers are not applicable.
According to the Qt documentation (and my understanding), it uses an array of pointers to the items, unless the item is not larger than a void*
and declared as movable (with Q_MOVABLE_TYPE).
In that case, the item is directly stored in the array and the reference will become invalid when your list will grow (the array of pointers will be reallocated).
QList
is not based on a STL container and has nothing to do with std::list
.
The invalidation rules specified for the STL containers are not applicable.
According to the Qt documentation (and my understanding), it uses an array of pointers to the items, unless the item is not larger than a void*
and declared as movable (with Q_MOVABLE_TYPE).
In that case, the item is directly stored in the array and the reference will become invalid when your list will grow (the array of pointers will be reallocated).
answered Mar 8 at 23:57
Romha KorevRomha Korev
2,2671423
2,2671423
Ah, that's why they can implement[]
access in O(1).
– ilya1725
Mar 9 at 1:31
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
add a comment |
Ah, that's why they can implement[]
access in O(1).
– ilya1725
Mar 9 at 1:31
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
Ah, that's why they can implement
[]
access in O(1).– ilya1725
Mar 9 at 1:31
Ah, that's why they can implement
[]
access in O(1).– ilya1725
Mar 9 at 1:31
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@ilya1725, compared to stl containers, QList is more of a std::deque, that's why there also exists QLinkedList, which is more of a list
– MasterAler
Mar 9 at 18:23
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@MasterAler, I did not know that, thank you. Why not call the containers the way they are, i.e. dequeue and list?
– ilya1725
Mar 11 at 15:11
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
@ilya1725, well, I just guess that this naming desicion comes from some average practice of Qt container's usage -- it's not an often situation when someone really needs a simple linked list, more likely that someone doesn't want/need QVector, complex server backends is not usually written in Qt, after all =). Thus, QList is multipurpose and efficient for average cases, all classes in designed to be used quickly and easily (like QTcpSocket is not as customizable as real socket, but is very straightforward when used). That's my assumption))
– MasterAler
Mar 13 at 11:09
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071969%2fpointer-to-an-element-in-qlist%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown