Description: In Qt, Windows as a change in the HTML Help QtAssistant.
(Listed in the article.
)
In the previous article, Qt help files (qch files, qhc file) we created.
In this article, Qt help files (qch files, qhc file) describes how to display any interest in the application.
Articles: Qt (8) QtAssistant the GUI of the Japanese
Articles: QtAssistant use in creating a file HELP
Articles: http://doc.trolltech.com/4.5/qthelp.html
Sample source code you used here:
Please observe the licensing terms described in the source code.
QtAssistant the display is the most common I think.
First, QtAssistant we'll see.
QtAssistant earlier, for the view class (QAssistantClient) were.
This is, prima facie, it seems to work now, so is not recommended here, do not use.
This is recommended QtProcess describes how to start with easily.
This sample is composed of the following file.
- sample.cpp
- Main program.Skip MainWindow is a detailed description of the screen.
- mainwindow.h
- QMainWindow MainWindow is inherited header screen.Omit a detailed explanation.
- mainwindow.cpp
- MainWindow is the source of the screen.And a detailed explanation later.
Qt use the Help file, use the HELP QtAssistant created in a file doc.qch, collection_doc.qhc used.
[mainwindow.cpp]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #include "mainwindow.h" #define HELP_FILE "collection_doc.qhc" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { // create menu. QMenu * pfileMenu = menuBar()-->addMenu(tr("&File")); // create status bar. QStatusBar *pstatus= statusBar(); pstatus-->showMessage(tr("Ready")); // create action. m_help_act = pfileMenu-->addAction("H&elp" ); m_help_act-->setShortcut(QKeySequence(QKeySequence::HelpContents)); m_help_act-->setStatusTip(tr("Show help")); m_help_change_act = pfileMenu-->addAction("Change Page Help" ); m_help_change_act-->setStatusTip(tr("Change Page Help")); m_help_change_act-->setEnabled(false); m_exit_act = pfileMenu-->addAction(tr("E&xit" )); m_exit_act-->setShortcut(tr("Ctrl+Q")); m_exit_act-->setStatusTip(tr("Exit the application")); // create help process. m_process_help = new QProcess(this); m_help_exec=false; // action connect. connect(m_help_act, SIGNAL(triggered()), this, SLOT(OnHelp())); connect(m_help_change_act, SIGNAL(triggered()), this, SLOT(OnHelpChange())); connect(m_exit_act, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(m_process_help,SIGNAL(started()), this,SLOT(OnStartedHelp())); connect(m_process_help,SIGNAL(finished(int , QProcess::ExitStatus )), this,SLOT(OnEndHelp(int , QProcess::ExitStatus ))); setWindowTitle(tr("SampleWindow")); resize(400, 300); } void MainWindow::OnHelp() { QStringList args; args << QLatin1String("-collectionFile") << ( qApp-->applicationDirPath() + "/" + HELP_FILE ) << QLatin1String("-enableRemoteControl"); m_process_help-->start(QLatin1String("assistant"), args); } void MainWindow::OnHelpChange() { QByteArray ba; ba.append("setSource qthelp://Sample_Help/doc/doc2.html"); ba.append('\0'); m_process_help-->write(ba); } void MainWindow::OnStartedHelp() { m_help_exec=true; statusBar()-->showMessage(tr("Started HELP(Assistant).")); m_help_act-->setEnabled(!m_help_exec); m_help_change_act-->setEnabled(m_help_exec); } void MainWindow::OnEndHelp(int , QProcess::ExitStatus ) { m_help_exec=false; statusBar()-->showMessage(tr("Closed HELP(Assistant).")); m_help_act-->setEnabled(!m_help_exec); m_help_change_act-->setEnabled(m_help_exec); } |
Make a simple explanation.
Lines 9-12, the menu, I have created a status bar.
Lines 15-25 are where the action is created.
- m_help_act: QtAssistant action to start.
- m_help_change_act: QtAssistant action switch pages.
- m_exit_act: The action to terminate the application.
Line 27-28, QtAssistant you start QProcess I have created.
Line 50-57, QProcess using QtAssistant We are starting up.
For more about the command parameters, http://doc.trolltech.com/4.5/assistant-details.html please see the.
Line 58-64, QProcess I'm using a switch QtAssistant page.
For more about the command parameters, http://doc.trolltech.com/4.5/assistant-custom-help-viewer.html please see the.
After the first 65 rows, QtAssistant Once the process is to enable the switching action.
Once you have QtAssistant process and disable the switching action.
It's easy.
QProcess to pass parameters to the startup, QString (List) at (QtAssictant specified as startup parameters),
but after starting, switch to the communication process, send with QByteArray (QtAssictant command parameters specified).
The screen displays the following to compile and run it.

This is just a simple menu screen.
So, File menu, Help'll click.
QtAssistant will be shown like a following image.

Continues, File menu, Change Page Help Click Let.
QtAssistant will be changed page like a following image.

Command, you can manipulate the screen.
I think a good many will be tested.
Command parameter details:
http://doc.trolltech.com/4.5/assistant-custom-help-viewer.html
Qt help files (qch files, qhc file) is unique in Qt applications, it can be shown.
In his own Qt I'd like to see a brief description of the application.
Pages: 1 2
You might also like:
Trackback URL
After Admin approves this comment, it will be shown.
Comments
Leave a Reply
