函数在Qt中无法正常工作
function is not working properly in Qt
我正在制作一个简单的 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");
}
单击按钮时启动此功能,但我的问题是,这不起作用!其次,您可以在代码中看到,为了提供更多信息,我使用了一个textBrowser
向用户显示正在发生的事情,例如重新挂载分区等,lineEdit_6
是lineEdit
小部件,用户将在其中粘贴引导动画的路径.zip。所以我的问题是当我单击按钮时,仅显示此内容
Bootanimation has been changed! Try shutting down your phone to see new bootanimation
我认为上面的所有内容都被跳过了,我不知道为什么? 谁能给我一些提示我错过了什么?
在这里,您混合了两种不同的方法来为 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。
Ui 需要 eventloop 来刷新自身。当您在一个函数调用中执行所有更改时,只有内部属性会更改,并且 gui 本身不会重新绘制。每次ui->textBrowser->setText(...);
后立即使用QCoreApplication::processEvents();
- QSqlquery prepare()和bindvalue()不工作
- 导入库可以跨dll版本工作吗
- 以螺旋方式打印矩阵的程序.(工作不好)
- 对象指针在c++中是如何工作的
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 为字符串中每 N 个字符插入空格的函数没有按照我认为的方式工作?
- C++为线程工作动态地分割例程
- 为什么我的 std::ref 无法按预期工作?
- 布尔比较运算符是如何在C++中工作的
- SampleConsensusPrerejective(ext.RANSAC)是如何真正工作的
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 为什么std::condition_variable notify_all的工作速度比notify_one快(对于随机请
- <<操作员在下面的行中工作
- 有人能解释一下为什么下界是这样工作的吗C++的
- ExtractIconEx:可以工作,但偶尔会崩溃
- C++中的memset函数工作不正常
- 当我在第一个循环中使用"auto"时,它工作正常,但是使用"int"它会给出错误,为什么?
- 为什么STD ::计数将常数传递给Lambda,而不是在弦上工作时而不是字符
- C++程序已停止工作-求解常微分方程