Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问QTreeWidgetItem::setText()调用后如何实时刷新界面. #3

Open
JoneyYang opened this issue Aug 17, 2020 · 5 comments
Open

Comments

@JoneyYang
Copy link

我在调用QTreeWidgetItem::setText()之后,控件的内容并不会立即刷新内容,而是在我鼠标划过之后才会刷新。

@shelllet
Copy link
Owner

shelllet commented Aug 18, 2020

理論上 QTreeWidgetItem::setText(int column, const QString &text) 之後應該不需要刷新。

可以試試 QTreeWidget的update函數

void update(const QModelIndex &index)

Updates the area occupied by the given index.

@shelllet
Copy link
Owner

很可能是你的顯卡問題,你在什麽系統上做應用?

@JoneyYang
Copy link
Author

很可能是你的顯卡問題,你在什麽系統上做應用?

我的环境是 Win10 , Qt 5.14.

我猜测是QT为了效率, 并不会立即绘制Item。 因为我发现,在Tree里面新插入一项,整个 Tree会立即刷新, 但是setText并不会。

update函数我尝试过, 但并没有效果。

@shelllet
Copy link
Owner

shelllet commented Aug 18, 2020

https://youtu.be/c8ZZ6h8rbtE
ui->treeWidget->topLevelItem(0)->child(0)->setText(0, ui->lineEdit->text());
Example

@shangfire
Copy link

使用dataChanged(QModelIndex(), QModelIndex());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants