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

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 766|回复: 2
收起左侧

[求助] QT程序能否如图所示文件名一步传送到位?

[复制链接]
冥界3大法王 发表于 2022-6-24 12:17
本帖最后由 冥界3大法王 于 2022-6-24 12:37 编辑

@wanxiangyu
还得请教专家们一个问题哟~~
话说在上一回书中,我们提到的那个贴子中。。
还有一个残留问题没有解决:

我简单的修改了一下代码内容如下:
void PatchDialog::on_listModules_itemDoubleClicked(QListWidgetItem *item)
{
     QString str = ui->listModules->currentItem()->text();   //这个编译成功啦~~
     Bridge::CopyToClipboard("Patch_" + str); //得到的列表项内容
}

image.png

然后呢?  请看配图 ! 如图所示哈 ~~   我想让剪贴板的内容一步到位  到   文件名中去 !
相关的完整代码如下:

[C++] 纯文本查看 复制代码
void PatchDialog::on_btnPatchFile_clicked()
{
    //get current module
    if(!ui->listModules->selectedItems().size())
        return;
    QString mod = ui->listModules->selectedItems().at(0)->text();
    PatchMap::iterator found = mPatches.find(mod);
    if(found == mPatches.end()) //not found
        return;
    PatchInfoList & curPatchList = found.value();

    //get patches to save
    QList<DBGPATCHINFO> patchList;
    for(int i = 0; i < curPatchList.size(); i++)
        if(curPatchList.at(i).status.checked)
            patchList.push_back(curPatchList.at(i).patch);
    if(!curPatchList.size() || !patchList.size())
    {
        SimpleInfoBox(this, tr("Information"), tr("Nothing to patch!"));
        return;
    }

    if(containsRelocatedBytes(curPatchList) && !showRelocatedBytesWarning())
        return;

    char szModName[MAX_PATH] = "";
    if(!DbgFunctions()->ModPathFromAddr(DbgFunctions()->ModBaseFromName(mod.toUtf8().constData()), szModName, MAX_PATH))
    {
        SimpleErrorBox(this, tr("Error!"), tr("Failed to get module filename..."));
        return;
    }

    //open the save file dialog
    int len = (int)strlen(szModName);
    while(szModName[len] != '\\')
        len--;
    char szDirName[MAX_PATH] = "";
    strcpy_s(szDirName, szModName);
    szDirName[len] = '\0';

    QString filename = QFileDialog::getSaveFileName(this, tr("Save file"), szDirName, tr("All files (*.*)"));
    if(!filename.length())
        return;
    filename = QDir::toNativeSeparators(filename); //convert to native path format (with backlashes)

    //call patchSave function
    DBGPATCHINFO* dbgPatchList = new DBGPATCHINFO[patchList.size()];
    for(int i = 0; i < patchList.size(); i++)
        dbgPatchList[i] = patchList.at(i);
    char error[MAX_ERROR_SIZE] = "";
    int patched = DbgFunctions()->PatchFile(dbgPatchList, patchList.size(), filename.toUtf8().constData(), error);
    delete [] dbgPatchList;
    if(patched == -1)
    {
        SimpleErrorBox(this, tr("Error!"), tr("Failed to save patched file (%1)").arg(error));
        return;
    }
    SimpleInfoBox(this, tr("Information"), tr("%1/%2 patch(es) applied!").arg(patched).arg(patchList.size()));
}



能否修改如愿呢? 谢谢~~

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

 楼主| 冥界3大法王 发表于 2022-6-24 12:33
本帖最后由 冥界3大法王 于 2022-6-24 17:22 编辑

现在 只要 在文件名处Ctrl+V 就会得到 【Patch_ + 列表项名】
已经很方便啦~~
能否再向前前进一步呢?
Eaglecad 发表于 2022-6-24 15:20
本帖最后由 Eaglecad 于 2022-6-24 15:27 编辑

QApplication::clipboard()->setText(str); 这样就把内容自动复制到剪切板了
QApplication::clipboard()->text();  这是从剪切板获取内容

char szDirName[MAX_PATH] = "";
strcpy_s(szDirName, szModName);
szDirName[len] = '\0';
这里路径跟上需要保存的文件名,那个文件名就自动出来了

免费评分

参与人数 1吾爱币 +4 热心值 +1 收起 理由
冥界3大法王 + 4 + 1 好的,一会吃完西瓜上机实践下,谢谢。

查看全部评分

您需要登录后才可以回帖 登录 | 注册[Register]

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

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

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

GMT+8, 2024-3-29 09:24

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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