Opening a chm file containing merged files in a Qt application - qt

In my Qt application we can open a help file (chm) by doing the following:
QDesktopServices::openUrl(QUrl::fromLocalFile(_PathToTheCHMFile));
This seems to be the suggested way of doing things. And it has worked up until now.
However, the documentation team has now changed how the chm files work. Now we are referencing a "master" file which only contains references to other chm files. The directory structure of the chm files is as follows:
master.chm
SUBDIR/
-> child1.chm
-> child2.chm
...
If open the master.chm file with hh.exe (the default tool in windows), everything looks perfect. However, from my Qt application, the help file opens, but there are no sub topics, just the root node.
I assume this is a search path issue, and it can't resolve the relative paths. There doesn't seem to be any way to configure the openURL call to run from a certain directory, or anything like that.
Thanks in advance

If you need to be able to access those elements properly, then you may need to change your applications current directory on the fly.
http://qt-project.org/doc/qt-4.8/qdir.html#details
http://qt-project.org/doc/qt-4.8/qdir.html#setCurrent
If that doesn't work, you may want to look into using QProcess::startDetached
http://qt-project.org/doc/qt-4.8/qprocess.html#startDetached
and specifying the working directory to be exactly where your master.chm is located.
You may want to specify some command-line arguments, too.
http://www.help-info.de/en/Help_Info_HTMLHelp/hh_command.htm
Hope that helps.

Related

What to do if Processing won't find a library?

No matter what I do, Processing just won't find this library. No matter where I put it or how many renames I do, Processing can't find it and I can't find an alternative anywhere. I basically only need it for the "Descriptive" class. And I know its in the correct spot because I have the library "minim" and Processing can find that. The DL link.
Anyone want to give it a shot and then give a solution (or walkthrough of what/how they did) if they find whats wrong? Or know of another library where this class is at?
The simplest way to load a non-standard library into a Processing sketch is to drag the .jar file onto the Processing editor.
You don't have to install the library in the libraries directory. Just find a file like YourLibrary.jar and drag it directly onto your sketch in the Processing editor.
This will automatically put the library jar file in the correct place, and you'll be able to use the jar in your sketch.
Shameless self-promotion: here is a guide on using libraries in Processing.
It is possible that you are putting the library in the wrong folder, click Preferences in Processing and look for Sketchbook Location (which is where you should copy the downloaded folder in) to make sure you are putting it in the right place. I have checked the download link and the site says you have to copy the entire unzipped folder into your libraries folder (which is located in your sketchbook folder) in order for it to work.
If you have checked what I suggested above and still cannot find a problem, refer to https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library which will hopefully help you.

Path to the project current dir in qt

I want to get a path to the project directory in Qt and reference the other files of my project relative to it. I know this issue have been already discussed here
Get current working directory in a Qt application
and here
How to get current working directory path of a Qt application?
but the answer is still unknown. In case it's impossible to get such a path then what is the approach of navigation among files of the Qt project.
Based on your comment, you are trying to:
Access some images which are being used in my program. I could of course put them into build target directory, but it becomes uncomfortable to pass my code to others.
The approach to store resource files in the project source directory and rely on such structure at runtime is not a greatest idea. I can't imagine the situation when mixing the concepts of initially decoupled source and build directories could be useful, correct me if I'm wrong.
So, according to your needs:
The most simple and plain way is to use the Qt resource system. The resource files are simply embedded into the executable, so there will be no need to access the file system.
Another way is the automatic deployment of the needed files. This answer describes the way to copy your files to the target directory using qmake.

Strange behavior of CHM project

Anybody can help me with a strange problem I am having with my CHM based project?
I took an existing CHM file and deconstructed the file using WinCHM. After that I added some new pages and compiled the project. The CHM file was created and everything looked great so far.
After that I put the entire folder (where the original CHM file was deconstructed) into SVN. When I opened the folder the next time I see that all the original formatting from the html pages is lost.
I cant seem to find a reason why. The css files are okay and i have not changed that at all. I know that finding a solution to this (or determining the problem) may not be easy for you guys with so little information.
But can you guys at least tell me what the problem might be?? We are talking possibilities that is all.
Somehow you are in different directories when running, so CHM compiler doesn't get a proper understanding of the CHM root ? E.g. you now run a batchfile via a shortcut instead of changing to the proper dir ? (either by cmd.exe or direct link?)y
If that is not it, try looking at it with some other CHM viewer (easier on non Windows, but e.g. kchmviewer builds for windows exist too). Sometimes they give more error information (but sometimes only in the console window)
Then update your question with what exactly went wrong.
The answer is so simple that I am surprised that it did not occur to me. The directories stylesheets, scripts and images are not in the same folder as the html files. These should be in the same folder.

"Add as Link" for JavaScript files returning 404 in debug

Using a Visual Studio 2010 ASP.net web application, I have several projects that share some JavaScript/css files. The most logical way for them to share these files is to place the files in a single folder and each project has them included with the "Add as Link" option. However, if I add the files this way when I'm debugging using either the Visual Studio Development server or debugging using a local IIS web server all requests for these files return 404 Not Found errors. If I publish the site then the files are copied but that obviously doesn't help with debugging.
Is there something I'm missing or is this a failing on VS's part?
To overcome this problem some time ago I created a 'MSBuild.WebApplication.CopyContentLinkedFiles' nuget package. This package adds MsBuild target which copies all content files added as link to project folder during build.
Note: if you use source control then it is better to add copied files (from Web Application folder) to ignore list.
I wouldn't really call that a failing, since you asked for that behavior in the first place: linked items in Visual Studio projects are actual links to external files. Those files can reside anywhere on the disk and are not copied into the project folder.
You might want to copy those files locally yourself during a pre-build event. That way, the files will remain synchronized and you won't duplicate them until your first compile.
The problem seems to be that the website runs right from your source folders, rather than from the bin folder. This means that the file will be missing, whether or not it is copied to the output folder.
It's probable that running from a local or remote web server would not have this problem, though I didn't get that working, and I'd rather not add IIS to my local machine if I don't have to.
Adding a pre-build copy command did work. Note that the current directory will be the bin folder. (You can use cd to echo the current directory to the build window if you want to see it):
If the file is in another solution, your command will look something like (three ..s: one to get out of each of bin, project, and solution folders):
copy ..\..\..\OtherSolution\OtherProject\Scripts\MyJSFile.js ..\Scripts\
If it's in the same solution, but a different project:
copy ..\..\OtherProject\Scripts\MyJSFile.js ..\Scripts
One minor issue is that the link to the file will collide with the new copy of the file, even if you don't add it to your project. As long as you make the link first, it seems to work. If you copied the file first, you'll have to manually delete the copy, and then refresh the solution explorer before before being able to add the link.
Select the link in Solution Explorer and then look at properties window and set Copy To Output Directory to Copy Always. Linked items are set to Do Not Copy by default.
BTW, you can copy many files as links very easily directly from Solution Explorer when using VSCommands 2010 extension.
See this blog post about a simple addition to your project file.
http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx

Which files should go into source control in a Flex Builder project?

I noticed that Eclipse (Flex Builder) generates hundreds of metadata files. Should I check them into my source control? They seem necessary, because if I delete them Flex Builder just opens up an empty workbench...
Some of these files plainly do not belong in source control (like .history files and some cache files). If I delete them my project opens up again without a hitch. But the list is long and there seem to be no clear separation between folders that contain files that belong in source control and those that do not.
I can't just shove them all into svn, even if I were to ignore the inefficiency, because Eclipse generates new ones constantly, with different names, which in turn also seem to be crucial for the project to load.
Can someone please enlighten me?
Don't check in the hundreds of metadata files. If you want to be able to check out the project in a way that it can just be imported, then check in:
.actionScriptProperties
.project
.flexProperties
And "html-template" and "libs". As Christian says, any resources you depend on. I usually keep those as separate Flex Library projects though.
I generally put all of my source code under src, and I check in src and all of its descendents. If my project relies on any external dependencies (e.g., the Cairngorm SWC, as3corelib, etc.), Flash/graphical assets, stylesheets, or resource files, I check those in, too. But I don't check in any generated (bin-*), intermediate or IDE-specific stuff, because having that stuff in source control doesn't seem to provide much practical benefit, and in my experience has only caused me headaches; in general, I check in the most minimal set of whatever I'd need -- given a clean FlexBuilder installation (or none at all -- for example, if I were compiling instead with mxmlc or compc) and an empty project -- to build the project successfully.
Most of the eclipse project files, like .project, .properties, everything in .settings, can go into your source control. As long as the files don't have user-dependent settings like file paths or local urls, you should be fine.
One method we use is creating local property files that don't get used in SCM, but are included in the ones that do. I.E an ant build file including a local.properties file which has local metadata.
What if the .actionScriptProperties, .project, or .flexProperties have user-dependent stuff in them? Typically this will be url or path information. What's the best practice way of externalizing this? I tried creating path variables, but this only works obviously for paths. Not for things like hostname, etc.

Resources