QTreeView did not refresh data when dataChanged was emitted
I have a very weird issue. Could anyone please help me out of this? Thanks in advance.
I have a QTreeview which shows data from a socket and it uses a custom QAbstractItemModel; When data arrives, dataChanged is emitted. And in the data method of my item model, I qDebug log information. The socket runs in a separate thread.
The weird thing is that if I set a breakpoint in the model's data method, then the method is hit and a cell of QTreeView is updated. But if there are no breakpoints in the data method, the method seems not to be called (no logging from qDebug) and the cell is not updated.
I guess it's related to thread stuff but I don't know what it is exactly. Any help will be greatly appreciated.
qt refresh qabstractitemmodel
add a comment |
I have a very weird issue. Could anyone please help me out of this? Thanks in advance.
I have a QTreeview which shows data from a socket and it uses a custom QAbstractItemModel; When data arrives, dataChanged is emitted. And in the data method of my item model, I qDebug log information. The socket runs in a separate thread.
The weird thing is that if I set a breakpoint in the model's data method, then the method is hit and a cell of QTreeView is updated. But if there are no breakpoints in the data method, the method seems not to be called (no logging from qDebug) and the cell is not updated.
I guess it's related to thread stuff but I don't know what it is exactly. Any help will be greatly appreciated.
qt refresh qabstractitemmodel
Do you really need to use threads? Qt sockets provide an interface to use them with signals/slots. So you can connectreadyRead
signal with slot and emit new siglal (i.e.dataReady
) when socket buffer has enough data to update your treeview.
– Bogdan
Dec 29 '18 at 12:34
The socket is in a thread and there is a third thread to do the heavy calculation before it emits the signal to the qtreeview.
– user2384278
Dec 29 '18 at 13:26
the correct logic in Qt is to use the readyRead signals to obtain the data, then send that data to another thread with the help of a new signal where you can do the heavy calculation. it is not necessary to execute the sockets in another thread.
– eyllanesc
Dec 29 '18 at 16:19
add a comment |
I have a very weird issue. Could anyone please help me out of this? Thanks in advance.
I have a QTreeview which shows data from a socket and it uses a custom QAbstractItemModel; When data arrives, dataChanged is emitted. And in the data method of my item model, I qDebug log information. The socket runs in a separate thread.
The weird thing is that if I set a breakpoint in the model's data method, then the method is hit and a cell of QTreeView is updated. But if there are no breakpoints in the data method, the method seems not to be called (no logging from qDebug) and the cell is not updated.
I guess it's related to thread stuff but I don't know what it is exactly. Any help will be greatly appreciated.
qt refresh qabstractitemmodel
I have a very weird issue. Could anyone please help me out of this? Thanks in advance.
I have a QTreeview which shows data from a socket and it uses a custom QAbstractItemModel; When data arrives, dataChanged is emitted. And in the data method of my item model, I qDebug log information. The socket runs in a separate thread.
The weird thing is that if I set a breakpoint in the model's data method, then the method is hit and a cell of QTreeView is updated. But if there are no breakpoints in the data method, the method seems not to be called (no logging from qDebug) and the cell is not updated.
I guess it's related to thread stuff but I don't know what it is exactly. Any help will be greatly appreciated.
qt refresh qabstractitemmodel
qt refresh qabstractitemmodel
asked Dec 29 '18 at 5:51
user2384278user2384278
31
31
Do you really need to use threads? Qt sockets provide an interface to use them with signals/slots. So you can connectreadyRead
signal with slot and emit new siglal (i.e.dataReady
) when socket buffer has enough data to update your treeview.
– Bogdan
Dec 29 '18 at 12:34
The socket is in a thread and there is a third thread to do the heavy calculation before it emits the signal to the qtreeview.
– user2384278
Dec 29 '18 at 13:26
the correct logic in Qt is to use the readyRead signals to obtain the data, then send that data to another thread with the help of a new signal where you can do the heavy calculation. it is not necessary to execute the sockets in another thread.
– eyllanesc
Dec 29 '18 at 16:19
add a comment |
Do you really need to use threads? Qt sockets provide an interface to use them with signals/slots. So you can connectreadyRead
signal with slot and emit new siglal (i.e.dataReady
) when socket buffer has enough data to update your treeview.
– Bogdan
Dec 29 '18 at 12:34
The socket is in a thread and there is a third thread to do the heavy calculation before it emits the signal to the qtreeview.
– user2384278
Dec 29 '18 at 13:26
the correct logic in Qt is to use the readyRead signals to obtain the data, then send that data to another thread with the help of a new signal where you can do the heavy calculation. it is not necessary to execute the sockets in another thread.
– eyllanesc
Dec 29 '18 at 16:19
Do you really need to use threads? Qt sockets provide an interface to use them with signals/slots. So you can connect
readyRead
signal with slot and emit new siglal (i.e. dataReady
) when socket buffer has enough data to update your treeview.– Bogdan
Dec 29 '18 at 12:34
Do you really need to use threads? Qt sockets provide an interface to use them with signals/slots. So you can connect
readyRead
signal with slot and emit new siglal (i.e. dataReady
) when socket buffer has enough data to update your treeview.– Bogdan
Dec 29 '18 at 12:34
The socket is in a thread and there is a third thread to do the heavy calculation before it emits the signal to the qtreeview.
– user2384278
Dec 29 '18 at 13:26
The socket is in a thread and there is a third thread to do the heavy calculation before it emits the signal to the qtreeview.
– user2384278
Dec 29 '18 at 13:26
the correct logic in Qt is to use the readyRead signals to obtain the data, then send that data to another thread with the help of a new signal where you can do the heavy calculation. it is not necessary to execute the sockets in another thread.
– eyllanesc
Dec 29 '18 at 16:19
the correct logic in Qt is to use the readyRead signals to obtain the data, then send that data to another thread with the help of a new signal where you can do the heavy calculation. it is not necessary to execute the sockets in another thread.
– eyllanesc
Dec 29 '18 at 16:19
add a comment |
2 Answers
2
active
oldest
votes
Possible you forgot update your QTreeView, in case of breakpoint this event happens automatically, but without it you should update QTreeView or its parent widget in program.
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
add a comment |
Just identified the root of the issue: The subnodes' parents are not correct. Thanks to all you guys. Happy new year!!!
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%2f53967068%2fqtreeview-did-not-refresh-data-when-datachanged-was-emitted%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Possible you forgot update your QTreeView, in case of breakpoint this event happens automatically, but without it you should update QTreeView or its parent widget in program.
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
add a comment |
Possible you forgot update your QTreeView, in case of breakpoint this event happens automatically, but without it you should update QTreeView or its parent widget in program.
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
add a comment |
Possible you forgot update your QTreeView, in case of breakpoint this event happens automatically, but without it you should update QTreeView or its parent widget in program.
Possible you forgot update your QTreeView, in case of breakpoint this event happens automatically, but without it you should update QTreeView or its parent widget in program.
answered Dec 29 '18 at 12:52
Yuriy RusinovYuriy Rusinov
6115
6115
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
add a comment |
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I thought when the dataChanged is emitted, the view would get data and update itself. Do I miss something important, such as what you said "update the view". May I know what I should do if updating is required?
– user2384278
Dec 29 '18 at 13:34
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
Hi Yuriy, I just found that cells in sub nodes don't update but the top cells are being updated. So I need to refresh the sub nodes or something else?
– user2384278
Dec 29 '18 at 14:05
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
You need to refresh them.
– Yuriy Rusinov
Dec 31 '18 at 19:50
add a comment |
Just identified the root of the issue: The subnodes' parents are not correct. Thanks to all you guys. Happy new year!!!
add a comment |
Just identified the root of the issue: The subnodes' parents are not correct. Thanks to all you guys. Happy new year!!!
add a comment |
Just identified the root of the issue: The subnodes' parents are not correct. Thanks to all you guys. Happy new year!!!
Just identified the root of the issue: The subnodes' parents are not correct. Thanks to all you guys. Happy new year!!!
answered Dec 30 '18 at 1:08
user2384278user2384278
31
31
add a comment |
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%2f53967068%2fqtreeview-did-not-refresh-data-when-datachanged-was-emitted%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
Do you really need to use threads? Qt sockets provide an interface to use them with signals/slots. So you can connect
readyRead
signal with slot and emit new siglal (i.e.dataReady
) when socket buffer has enough data to update your treeview.– Bogdan
Dec 29 '18 at 12:34
The socket is in a thread and there is a third thread to do the heavy calculation before it emits the signal to the qtreeview.
– user2384278
Dec 29 '18 at 13:26
the correct logic in Qt is to use the readyRead signals to obtain the data, then send that data to another thread with the help of a new signal where you can do the heavy calculation. it is not necessary to execute the sockets in another thread.
– eyllanesc
Dec 29 '18 at 16:19