PDA

View Full Version : AssistantClient - Qt4.4



Ankitha Varsha
15th May 2008, 09:38
Hi,

I am working in Qt4.4.

I am trying to show a custom html page in Qt's Assistant.

As per information in Qt Assistant, I am using QProcess to achieve the same.
when I try to show some html page, I get this standard 404 - "The page could not be found" error after assistant gets launched.

The html page I am trying to show is existing for sure in the path given to "SetSource".

Following is the code. I am not sure what am I missing here.
As a matter of fact, I get this page not found error if I try to load an html page from Qt's Assistant documentation for example,
path = "C:/Qt/4.4.0/doc/html/templates.html".

Please let me know whats wrong with my code ...

Can anyone pls tell me also, if it is possible to add my application specific help contents to the existing help contents in the Qt Assistant?
For Ex:
"Qt Assistant Manual"
" QMake Manual"
......
"MyApplication Manual"

Kindly Let me know.


void MainWindow::showHelp()
{
// Check if assistent is already running
if (d->process->state() == QProcess::Running)
return;

// start the process bt giving assistent path as argument
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
#if !defined(Q_OS_MAC)
app += QLatin1String("assistant");
#else
app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
#endif

QStringList args;
args << QLatin1String("-enableRemoteControl");

// Launch the assistant
d->process->start(app, args);

if (!d->process->waitForStarted())
{
QMessageBox::critical(this, tr("Remote Control"),
tr("Could not start Qt Assistant from %1.").arg(app));

return;
}

// Show the desired page : THE PROBLEM IS HERE
QString command = QLatin1String("SetSource ") + "C:/demos/temp.html";
sendCommand(command);
}

void MainWindow::sendCommand(const QString &cmd)
{
if (d->process->state() != QProcess::Running)
return;
if (!d->process->isWritable() || d->process->bytesToWrite() > 0)
{
QMessageBox::information(this,"ERROR","Unable to send request: Assistant is not responding.");
return;
}

QTextStream str(d->process);
str << cmd << QLatin1Char('\0') << endl;
return;
}

Best Regards

aamer4yu
15th May 2008, 11:11
I guess you look at "Simple Text Viewer" example in the Qt Demo... it uses the QAssistantClient class.
You will find the example in examples/assistant directory of ur Qt installation.

Hope this helps :)

Ankitha Varsha
15th May 2008, 11:59
Hi,
Sadly, simpleTextViewer example doesn't show anything when Help->Help Contents is triggered. Actually , it internally calls showpage() of assistantclient to show simpleTextViewer's index.html

Here, I am quoting the information provided in Qt Assistant for QAssistantClient class.

"The QAssistantClient class provides a means of using Qt Assistant as an application's help tool.
Note: This class is obsolete and only required when using the old Qt Assistant, now called assistant_adp. If you want to use the new Qt Assistant as a remote help viewer, simple create a QProcess instance and specify assistant as its executable. "

The code pasted by me in my question is almost copy paste of the other Qt Example
examples\help\remotecontrol.

My Problem or my Questions remain same:
1. How can I show other HTML pages in Qt Assistant? I am already using "SetSource " and the html path which is not working as explained in my last qn.

2. How can I add to the contents of Qt Assistant , My application help contents, If at all its possible

Best Regards