-1

我正在制作一个简单的 GUI 程序来更改 Android 手机的启动动画,但是从过去 4 天开始我遇到了一个问题,我不知道是什么原因,这是我的代码

void MainWindow::bootanim1()
{   
    QProcess rootboot;

    QStringList path6,boottarget;
    path6<<ui->lineEdit_6->text();

    boottarget<<path6<<" /system/media";
    ui->textBrowser->clear();
    ui->textBrowser->setText("Remounting partitions...");
    rootboot.start("bbin\\adb shell su -c \"busybox mount -o remount,rw /system\"");
    rootboot.waitForFinished();
    ui->textBrowser->setText("\nInstalling bootanimation.zip");
    rootboot.start("bbin\\adb push ",boottarget);
    rootboot.waitForFinished();
    ui->textBrowser->setText("\nBootanimation has been changed! Try shutting down your phone to see new bootanimation");
}

单击按钮时会启动此功能,但我的问题是,这不起作用!其次,您可以在代码中看到,为了提供更多信息,我使用 atextBrowser向用户显示正在发生的事情,例如重新安装分区等,并且lineEdit_6lineEdit用户将粘贴 bootanimation.zip 路径的小部件。所以我的问题是当我点击按钮时只显示这个

Bootanimation has been changed! Try shutting down your phone to see new bootanimation

我认为上面的所有内容都被跳过了,我不知道为什么?谁能给我一些关于我缺少什么的提示?

4

2 回答 2

1

在这里,您混合了两种不同的方法来为 QProcess 提供参数:

boottarget<<path6<<" /system/media";
rootboot.start("bbin\\adb push ",boottarget);

第一种方法在一个 QString 中给出程序名称和参数。

第二种方法在 QStringList 中给出参数。

您试图在程序名称字符串中给出一个参数(“push”)。当其他参数在 QStringList 中给出时,它不起作用。最后一个参数在开头也包含可疑的空间,虽然我不知道它是否会导致问题。试试这个:

QStringList args;
args << "push" << path6 << "/system/media";
rootboot.start("bbin\\adb", args);

path6 变量可能应该是 QString 而不是 QStringList。

于 2012-08-07T14:52:56.423 回答
0

UI 需要 eventloop 来刷新自己。当您在一个函数调用中进行所有更改时,只会更改内部属性,并且 gui 本身不会重新绘制。QCoreApplication::processEvents();每次后立即使用ui->textBrowser->setText(...);

于 2012-08-07T13:54:01.273 回答