Unable to get a custom helpfile to work from inside a Qt Application using Qt Assistant - c++

I am trying to learn how to use Qt Assistant for displaying a custom help in an application.
I found an example on Qt site:
http://qt-project.org/doc/qt-4.7/help-simpletextviewer.html
(using Qt 4.7.3)
All the source files needed are at the site above. I created html and png files and placed them in a "help" folder inside the project folder.
Running Qt Assistant from command line works great.
Loading the help file in the Assistant also works. What I can't get to do is to load the start page in the help file, as explained in this section:
http://qt-project.org/doc/qt-4.7/assistant-custom-help-viewer.html#id-0c628592-dd04-4465-94b1-e5d4a91d7cd4
void Assistant::showDocumentation(const QString &page)
{
if (!startAssistant())
return;
QByteArray ba("SetSource ");
ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/");
proc->write(ba + page.toLocal8Bit() + '\n');
}
With the detailed explanation of SetSource showing
setSource <Url> Displays the given <Url>. The URL can be absolute or relative
to the currently displayed page. If the URL is absolute, it has to be
a valid Qt help system URL; i.e., starting with "qthelp://".
I don't have a web page... but i tried to display the index from the local set of files, and i always get
a 404 error saying "cannot load page blahblah/help/index.html"
How can I create a local path as they say, or how can I create a "valid Qt help system URL" ?``
Note: SetSource and setSource have exactly the same results... and documentation and their own examples use them both... are these options not case sensitive ?
I answered my own question with a solution that doesn't seem right though... I would appreciate a better answer.

There must be something wrong with either my solution or the documentation...
I was able to get the page to display by changing an option...
replace QByteArray ba("SetSource ");
with QByteArray ba("Set Source ");

Related

Why is my windows shell extension being invoked when I run an executable as administrator?

I'm working on a project that integrates with the Windows 10 file explorer to allow users to open selected files in our program. The shell extension I made works fine for the most part, but the problem I'm having is that my extension's IShellExtInit::Initialize(...) and IContextMenu::InvokeCommand(...) are being invoked when I right click an executable in my start menu results and click "Run as administrator". As far as I can tell, the only point in my code where I can confirm that my extension should actually be running when it is invoked is in DllGetClassObject(...) by checking that rclsid and my extension's GUID are equal.
For the basic setup of the shell extension, I followed this video series. The example extension in the videos only appeared for text files, but I changed mine to work on all file types.
Does anyone have any idea where this problem could be coming from? Here are the relevant parts of my code: https://gist.github.com/caevrobe/2865b5f472d668352a7a91fb5c66953a
I found a solution to this issue here. My fix was to return E_INVALIDARG if pici->lpVerb != NULL in my IContextMenu::InvokeCommand(...). When invoking "Run as administrator" pici->lpVerb was "runas". When using my extension through the context menu normally, it was null.
HRESULT MyContextMenuHandler::InvokeCommand(LPCMINVOKECOMMANDINFO pici) {
if (pici->lpVerb != NULL)
return E_INVALIDARG;
// rest of your code...
}
I'll leave the question up in case anyone else has the same issue.

Hosting help content online

I'm trying to package some of my MFC applications as Windows 10 apps using Desktop Bridge.
I am having no end of trouble getting my HTML help file (CHM) included and working with the installed program (new versions of VS don't include the help file, and using workaround to include that file results in a file that I don't have the rights to access).
So it makes me wonder about hosting the online help on my website. A couple of the issues that arise is how best to host multiple help topics, and how to override (on a application-wide basis) the behavior of accessing help topics. (My app is dialog-based.)
So I just wondered if anyone else has done this already. I'd be curious to review how these issues were addressed. I was not able to find anything online.
I do host my html help in a single document, using html anchors to get to the topic of interest. If you have multiple pages, adapt MyHelp accordingly.
I didn't actually use the Desktop Bridge but wondered if you have tried something like this:
BOOL CMyDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
MyHelp(_T("HIDD_MYDIALOG")); // HTML anchor goes here
return CDialog::OnHelpInfo(pHelpInfo);
}
...
// a global helper function for showing help
void MyHelp(LPCTSTR anchor)
{
extern CMyApp theApp;
TCHAR *cp, buffer[1000];
// look for the html document in the program directory
strcpy(buffer, _T("file:///"));
DWORD dw = GetModuleFileName(theApp.m_hInstance, buffer + strlen(buffer), sizeof(buffer));
if (cp = strrchr(buffer, '\\'))
{
strcpy(cp+1, _T("MyHelpDocument.htm#"));
strcat(cp+1, anchor);
// for some reason, I don't want the default browser to open, just the Internet Explorer
ShellExecute(NULL, _T("open"), _T("iexplore"), buffer, NULL, SW_SHOWNORMAL);
// or, for real online help, use just '_T("http://myurl.com/myonlinehelpdocument.html#") + anchor'
// instead of 'buffer' and ommit all before ShellExecute()
}
}
I'm not sure if ShellExecute will behave the way it used to in the shop app though. But certainly there will be a way to open a URL somehow. You might want to try if the Internet Explorer ActiveX works to display your help pages inside the app.

Read window's registry in QT

I want to list all application which had been installed by reading uninstall registry file from HKEY_CURRENT_USER. But look like it can't be done by using QSettings, for some security reason ( i guess ).
QSettings maya("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall
People suggest to use WinAPI to accomplish this (at least, on Window platform)
Can somebody guide me how to add and use this lib please?
Thank
In order to get the list of all sub items under the "Uninstall" one in the Windows registry you need to use QSettings::childGroups() function, i.e:
QSettings m("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
QSettings::NativeFormat);
QStringList ak = m.childGroups();
This will return the list of all installed applications.
UPDATE:
After getting the list of installed applications one can read the installation details. There are two ways for doing that. For example to read the "UinstallPath" key for "Autodesk Maya 2014" application:
m.beginGroup("Autodesk Maya 2014");
QString path = m.value("UninstallPath").toString();
m.endGroup();
or simply:
QString path = m.value("Autodesk Maya 2014/UninstallPath").toString();

KDE writing (too many) in the console

I'm developping a Qt GUI application.
My problem is that I use the console for another thread (it write his comunication in it), and the main problem is that when I create a QFileDialog (in order to select a script file), KDE is wrinting useless informations (for me at least).
Is there a way to remove all possibility from my QFileDialog to write anything into the consolethat ? Is there a trick to switch main output to another (useless) target ?
My code (but I don't think it's really gonna help you) :
void MyGUI::setPathWithFileExplorer()
{
QFileDialog dlg;
dlg.resize(320,240);
QString fileName = dlg.getOpenFileName(this, tr("Open script file"), "~/", tr("Script Files (*.js)"));
if(fileName != "")
ui->editScriptPath->setText(fileName);
}
Output :
kded(21003) Mollet::KioSlaveNotifier::onDirectoryEntered: "trash:/"
kded(21003) Mollet::KioSlaveNotifier::onDirectoryLeft: "trash:/"
kded(21003) Mollet::KioSlaveNotifier::onDirectoryEntered:
"file://[PATH TO MY USER FOLDER]" kded(21003)
Mollet::KioSlaveNotifier::onDirectoryLeft:
"file://[PATH TO MY USER FOLDER]" kded(21003)
Mollet::KioSlaveNotifier::onDirectoryEntered:
"file://[PATH TO MY USER FOLDER]" kfilemodule(21676)
KSambaSharePrivate::testparmParamValue: We got some errors while
running testparm "Load smb config files from /etc/samba/smb.conf
Loaded services file OK. WARNING: The setting 'security=ads' should
NOT be combined with the 'password server' parameter. (by default
Samba will discover the correct DC to contact automatically). WARNING:
You have some share names that are longer than 12 characters. These
may not be accessible to some older clients. (Eg. Windows9x,
WindowsMe, and smbclient prior to Samba 3.0.) "
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed:
Permission non accordée QFileSystemWatcher: failed to add paths:
/var/lib/samba/usershares
I would suggest using kdebugdialog and then Deselect All. Here you can see an inline screenshot on my machine.
Failing that, you could always use QFile to log your output into a dedicated file, and then monitor that in a separate prompt or application.
If you go down that way, you could even take a look at the logger functionality added in 5.2 if you happen to be able to use that version.

Getting an incorrect permissions screen in the webview Blackberry 10 Cascades Beta 3 SDK in Dev Alpha Simulator

I am trying to make dynamically generated html 5 graphs show up in a webview in Blackberry 10 Cascades. I have confirmed the html5 that I have generated, draws the correct graphs. My problem is that when I try to implement this in the Blackberry 10 Cascades Beta 3 SDK (using the Blackberry 10 Dev Alpha Simulator), the webview that is supposed to show the graph, just looks like this:
Here is the code that leads to this error:
//html_ already contains the html-5 code to make the graph at this point in the code
//This is the file path to a local file that is actually accessable in the emulator
//and not just from Windows
//
QFile *chartFile = new QFile("app/native/assets/data/chart.html");
if (chartFile->open(QIODevice::WriteOnly)) {
chartFile->write(html_.toUtf8());
chartFile->flush();
chartFile->close();
}
if (chartFile) delete chartFile;
if (graphView_) {
graphView_->setHtml("");
graphView_->setUrl(QUrl::fromLocalFile("app/native/assets/data/chart.html"));
}
I checked the permissions of that file, put they are all Allow (777 permissions for those who know Unix style permissions).
I added access_internet to the bar-descriptor.xml, eventhough my app was already able to access remote sites, just to see if that would fix it, but it did not.
I've been searching around trying to find a solution to this problem, but I have not.
If anyone could help me out with this, it would be greatly appreciated.
-------------------------------------------------------
Update:
I changed the code to set the html directly, now I have this:
if (graphView_) {
graphView_->setHtml(html_, QUrl("app/native/assets/data/chart.html"));
}
But nothing shows. It seems I have the wrong relative path relative to my base url.
My base url is this: QUrl("app/native/assets/data/chart.html")
My relative paths all begin with: ./Highcharts/js/...
My relative paths are located under: app/native/assets/data/Highcharts/js
It seems to me that I this should work, but when I do this, I just a blank screen, as if it can not find my relative paths. So I don't know what's going on here either.
I found a solution that works. I'm using the first approach, not the updated approach, but instead of
graphView_->setUrl(QUrl("app/native/assets/data/chart.html"));
I'm using:
graphView_->setUrl(QUrl("local:///assets/data/chart.html"));
And I have left the rest of the code the same, and it works.