吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1089|回复: 9
收起左侧

[求助] QT creator 中能不能用几行代码得到当前行值(项目)?

[复制链接]
冥界3大法王 发表于 2022-6-23 21:21
比如在QT creator中随便拉一个ListBox , 弄两行内容。。。




void CodepageSelectionDialog::on_listCodepages_clicked(const QModelIndex &index)
{
    QString str = QString::number(ui->listCodepages->currentRow());
    Bridge::CopyToClipboard(str);                                            //可是得到的该索引值
}




没学过,也学不会。。。

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wihn 发表于 2022-6-23 21:48
试一下ui->listCodepages->CurrentItem()?
 楼主| 冥界3大法王 发表于 2022-6-23 22:31
wihn 发表于 2022-6-23 21:48
试一下ui->listCodepages->CurrentItem()?

C:\x64dbg_2\src\gui\Src\Gui\PatchDialog.cpp:712: error: C2039: “CurrentItem”: 不是“QListWidget”的成员
zsj118106 发表于 2022-6-24 08:37
jamesmeng 发表于 2022-6-24 08:49
QString str1 = index.data().toString();
wanxiangyu 发表于 2022-6-24 08:59
QString str = ui->listCodepages->currentItem()->text();

免费评分

参与人数 1吾爱币 +2 热心值 +1 收起 理由
冥界3大法王 + 2 + 1 成功了朋友!

查看全部评分

ryosga 发表于 2022-6-24 11:06
index.row()  // 行号

int QModelIndex::row() const
Returns the row this model index refers to.
 楼主| 冥界3大法王 发表于 2022-6-24 11:28
wanxiangyu 发表于 2022-6-24 08:59
QString str = ui->listCodepages->currentItem()->text();
void PatchDialog::on_listModules_itemDoubleClicked(QListWidgetItem *item)
C:\x64dbg_2\src\gui\Src\Gui\PatchDialog.cpp:710: warning: C4100: “item”: 未引用的形参

{
     QString str = ui->listModules->currentItem()->text();
     Bridge::CopyToClipboard(str); //得到的列表项内容
}

@wanxiangyu
哥们,你这个编译成功了,但有一个编译的错误提示。。。

wanxiangyu 发表于 2022-6-25 11:38
可以使用Q_UNUSED()来避免编译警告。
这也写

void PatchDialog::on_listModules_itemDoubleClicked(QListWidgetItem *item)
{
Q_UNUSED(item);
QString str = ui->listModules->currentItem()->text();
Bridge::CopyToClipboard(str); //得到的列表项内容
}


警告的原因是你有参数未使用。

免费评分

参与人数 1热心值 +1 收起 理由
冥界3大法王 + 1 谢谢@Thanks!

查看全部评分

wqc159 发表于 2022-6-25 21:46
QT 应该有帮助手册的,qtCreate 里面 F1 很方便。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-3-29 07:49

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表