Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 求助:MacX86使用qprocess时严重卡顿
Forum Update on Monday, May 27th 2025

求助:MacX86使用qprocess时严重卡顿

Scheduled Pinned Locked Moved Unsolved Chinese
1 Posts 1 Posters 215 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sprkxr
    wrote on last edited by
    #1

    MacX86使用qt5.15.8版本,执行以下demo时主进程卡顿严重,使用instruments发现每次process-start()都会造成severe hang,且cpu占用极高,为什么?

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    timer = new QTimer();
    connect(timer, &QTimer::timeout, this, &MainWindow::Read);
    QPushButton *button = new QPushButton("按钮", this);
    connect(button, &QPushButton::clicked, this, &MainWindow::OnBtnClicked);
    }

    void MainWindow::Read()
    {
    QThread *th = QThread::create([=] {
    QSharedPointer<QProcess> process(new QProcess);
    QStringList arg;
    arg << "ls"<< "-l";
    process->start("bin/zsh", arg);
    qDebug()<<arg;
    });
    connect(th, &QThread::finished, th, &QThread::deleteLater);
    th->start();
    }
    void MainWindow::OnBtnClicked()
    {
    Read();
    timer->start(8000);
    }

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved