I am trying to use Qt 4.8 for proxy resolution, when I have a proxy set in the system configuration under Windows.
My question is that when I set my system settings to use a PAC file, I can use the QNetworkProxyQuery and QNetworkProxy classes to resolve that PAC file for a given domain. However, is there a way I can obtain the actual PAC file contents itself using Qt functionality (or even just the location of the PAC file that is specified in the system settings), rather than have Qt resolve it for me? I know I can use Qt calls to pull down the file manually, but I would have to get the location of the PAC file first as well.
Regards,
Related
I have the following file I need to open in a windows explorer window
C:\Users\Public\Documents\folder1\test.txt
So far opening this file using the above path is fine and I can read it as usual.
However when trying to open this this folder through Windows Explorer using wxExecute((wxChar **)cmd, wxEXEC_ASYNC, NULL); where cmd is the above path(minus the file), It opens to my user documents.
I've tried various Windows API functions to get the path, some including where Public Documents has it's own ID and these still generate the path I already have. Are there any CLI options I can give to Windows Explorer so that it can actually open Public Documents without reverting to my User Documents folder?
First of all, why do you cast your string to wxChar**? This just can't be right.
Second, you should be using wxLaunchDefaultApplication() instead of "raw" wxExecute() in the first place (FWIW wxLaunchDefaultApplication() is a straightforward wrapper for ShellExecute() under MSW, while wxExecute() is much more complicated).
It's undocumented, but has worked across multiple windows Versions since at least XP with the following command line:
explorer.exe /select,"path-to-open"
Note the comma, and make sure the path is quoted. The path may include a file name, in which case that file gets selected.
(With Windows 10, it's actually a good idea to use a file name, since otherwise the parent folder is opened with the specified sub folder selected)
Should be the same with CreateProcess, ShellExecute, or system(), or whatever comfort wxWidgets offer.
Actually turned out to be an issue with wxExec from wxWidgets. Converting the command to a ShellExecute opened it up just fine. Potentially Widgets 2.9.5 can't handle Windows 10's pseudo folders and weirdness?.
I am trying to open a pdf manual for some hardware from within my application. It will be triggered from the help menu. I can't seem to get my application to open a file from a relative path using the OS default application. I found
QDesktopServices::openUrl(QUrl("file:///home/folder/Manual.pdf"));
referenced on the Qt forums and this works for me except I am going to install my software on another computer and the absolute path won't be the same. I'd like to install the manual next to my application and open it with something like
QDesktopServices::openUrl(QUrl("file:///Manual.pdf"));
but this fails to open with
ShellExecute 'file:///Manual.pdf' failed (error 2).
Has anyone done this before?
You can retrieve the absolute path with
QString a = QFileInfo("Manual.pdf").absoluteFilePath();
then pass it to QUrl, this way:
QUrl url = QUrl::fromLocalFile(a);
If Manual.pdf is in the folder of the executable, use:
QDesktopServices::openUrl(QUrl("file:///" + QApplication::applicationDirPath() + "/Manual.pdf"));
If you later decide to put the pdf in a dedicated sub-folder, e.g. doc, in the code above replace /Manual.pdf with /doc/Manual.pdf.
Using Qt 5.9 I codded a spreadsheet program and then created an installer for it by Qt Installer Framework (QtIFW2.0.1). Then I sent the program to many of my friends. They installed the app on their Windows machine and now using it, but they have all have a common problem:
when they save files of the app, those files are shown as "unknown" files on Desktop.
The problem is only with the shape and appearance of the stored files not their functionality, and they are opened by the app if double clicked.
The question is, what changes in the code is needed to have the program make its files' shape/appearance shown known?
For example, we offer the code a specific shape using an image file or like that, to be mapped on the stored files and that way they are shown known.
This has actually nothing to do with Qt or C++ itself. You just need to register your file extension in Windows shell, so it can be understood by other Windows components/shells.
Here is general information about File Types and File Associations under windows.
You need to make some Windows Registry entries which look like this:
example.reg:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\myfirm.myapp.v1\shell\open\command]
#="c:\path\to\your\app.exe \"%1\""
[HKEY_CURRENT_USER\Software\Classes\.myextension]
#="myfirm.myapp.v1"
Here you can read how it works in general
change myfirm.myapp.v1, .myextension and path to your .exe to your prefered names.
Now Windows will know what the files with extension .myextension should be opened by your app. And if you double click on this files your app will be run with path to file as an argument. You can get it in your main() function
To set icon for your extension add Registry entry in Software\\Classes\\.myextension\\DefaultIcon and set it default value to the full path to your app, so windows can get an icon for extension from your .exe app file.
You can also do it at runtime directly in your app:
QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES", QSettings::NativeFormat);
QString path = QDir::toNativeSeparators(qApp->applicationFilePath());
s.setValue(".myextension/DefaultIcon/.", path);
s.setValue(".myextension/.","myfirm.myapp.v1");
s.setValue("myfirm.myapp.v1/shell/open/command/.", QStringLiteral("\"%1\"").arg(path) + " \"%1\"");
EDIT: One more, to do it with Qt Installer look at the answers here
On http://developer.toradex.com/software-resources/arm-family/windows-ce/tegra/release-details?view=release-roadmap&issue=10304 it is stated that one should "Copy webservices.dll manually to the target folder \Flashdisk\System\" in order to fix a problem with Ethernet debugging. My problem is that I have no idea where I should copy the file from. Any ideas?
This is for WEC2013.
The file is located in your platform builder path if you build your own CE image:
C:\WINCE800\public\COMMON\oak\target\ARMV7\retail\webservices.dll
If you use a Toradex Prebuilt image, get in contact with the support team, they will probably send the driver to you: https://www.toradex.com/support/support.
I have my application with all the translations working perfectly except the 'OK' and 'Cancel' contained in the wxTextEntryDialog dialog. How can I get these to translate properly? Even the wxMessageBox is working fine when using OK and Cancel but wxTextEntryDialog doesn't just seem to translate to any other language.
I have used the following snippets for the languages assignment within my code:
wxLocale m_locale; // locale we'll be using (this is defined in the header file of my app)
// Within the source
lang = wxLANGUAGE_CHINESE_SIMPLIFIED; // for e.g. could be any language
m_locale.Init(lang);
// normally this wouldn't be necessary as the catalog files would be found in the default locations, but when the program is not installed the
// catalogs are in the build directory where we wouldn't find them by default
wxLocale::AddCatalogLookupPathPrefix(wxT(LanguagePath));// add path of install
// Initialize the catalogs we'll be using
m_locale.AddCatalog(_("messages")); // .mo file generated by my application language specific .mo file
Thanks in advance for any help.
Does your call to Init() succeed? You should really check for its return value, it's possible that it doesn't find wxstd.mo, which contains translations for all the messages used inside wxWidgets, because you call it before setting the lookup path. You need to
Ensure that wxstd.mo is available in your catalog path.
Call Init() after setting this path.
Check its return value.
Thanks #VZ. for the insight. Your approach helped me debug my application better i.e. I was able to see that the Init() did not succeed by checking the return value. With this I was able to investigate further. Also, the wxstd.mois just the default .po generated .mo (not translated so why would I require this?)
Solution: I had to add the wxWidgets translation files i.e. the .mo generated catalog files from the .po files contained in the <wxdir>/locale/. I had to copy them to the same directories as my messages.mo. Hence, the working code looks like this for Simplified chinese.
wxLocale m_locale; // locale we'll be using (this is defined in the header file of my app)
// Within the source
lang = wxLANGUAGE_CHINESE_SIMPLIFIED; // for e.g. could be any language
wxLocale::AddCatalogLookupPathPrefix(wxT(LanguagePath));// add path of install
m_locale.Init(lang, wxLOCALE_CONV_ENCODING);
m_locale.AddCatalog(wxT("zh_CN")); // This is the .mo file I generated from the wxWidgets .po files
// Initialize the catalogs we'll be using
m_locale.AddCatalog(_("messages")); // .mo file generated by my application language specific .mo file
I did not include the checks for a purpose because I want the application to run in english even if the language is not supported but I did use it for debugging