QT ListWidget 项目单击进入字符串

发布于 2024-09-28 01:01:25 字数 335 浏览 0 评论 0原文

我试图仅单击列表小部件中的项目列表中的项目。

我在用户界面中右键单击,然后转到插槽:

void main::listWidget_itemClicked(QListWidgetItem* item)

在那里我可以运行命令等...但我希望将单击的所选项目设置为字符串...我尝试使用 CONNECT/SIGNAL 路线,但我却一无所获。

理论上它看起来像这样: QString text = ui->listWidget->itemClicked(); obv 这是错误的,但我认为它表达了我想要做的事情......

我该怎么做?

I am trying to just click on an item in a list of items in a listwidget.

I right clicked in my UI and went to the slot:

void main::listWidget_itemClicked(QListWidgetItem* item)

In there I can run commands ect... But I want the selected item that I click on to be set to a String... I tried using the CONNECT/SIGNAL route, but I came up empty there.

It would theoretically look like this: QString text = ui->listWidget->itemClicked(); obv this is wrong, but I think it expresses what i am trying to do....

How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍白女子 2024-10-05 01:01:25

如果我没理解错的话,您只想将单击的项目设置为新字符串,对吧?

item->setText(someQString)

编辑:

我不确定“将其设置为字符串”是什么意思,但您可以使用以下命令检索项目的文本(QString)

item->text()

If I get you right, you just want to set the clicked item to a new String, right?

item->setText(someQString)

Edit:

I'm not sure what you mean with "set it to a string", but you can retrieve the text (a QString) of the item with

item->text()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文