Important: Please read the Qt Code of Conduct -

Expanding all items in the QT Assistant TOC tree

  • I'm using Qt Assistant (as a QProcess) to display my app's documentation and I would like to fully expand the Table of Contents tree automatically so the reader can quickly find the section he/she needs.

    Awhile back, I found that passing an "expandToc -1" argument (as a QByteArray) to the running process causes Assistant to expand the tree like I want. The line break at the end of the instruction is necessary (Assistant hangs if I omit it).

    The Assistant QProcess works but the expand instruction isn't very reliable. Once Assistant is running, the tree usually expands for a split second and then collapses down to the root node again (very rarely, the tree stays fully expanded like it's supposed to). It's really annoying because there seems to be no pattern to this bug that would help me solve it.

    Does anybody know why this is happening?

    Here's the code that controls the Assistant process:

    @ QProcess *p=new QProcess();
    QStringList args;

    #ifdef _WIN32
    args << "-collectionFile" << "robojournal.qhc"
    << "-enableRemoteControl";

    #ifdef unix
    args << "-collectionFile" << collection_path
    << "-enableRemoteControl";
    // Spawn the Assistant process with the OS-specific path-to-binary and args.
    QString exec=assistant + " " + args.join(" ");
    p->start(exec, QIODevice::ReadWrite);

            // Instruct Qt Assistant to completely expand the TOC immediately after launch. This saves
            // the user lots of pointless clicking.
            QByteArray input;
            input.append("expandToc -1\n");
            if (!p->waitForStarted()){

Log in to reply