Qt localization - c++

I have some problems with the localization of Qt programs.
At my computer all good but when i send my program to other users they can not see symbols of some languages. In this case I tested the Thai language.
Program output on screenshots:
My cpu OS: Windows 7 Ultimate x64 SP1
http://myprintscreen.com/s/1id
User cpu OS same: Windows 7 Ultimate x64 SP1
http://myprintscreen.com/s/1ie
User can print the Thai language in Microsoft Word and Notepad++ but not in the input fields of Qt.
And we found some interesting bug (http://myprintscreen.com/s/1if): If you copy the Thai text from a Microsoft Word in QTextEdit it displayed normally. QLineEdit and QPlainTextEdit do not display properly.
On Windows XP x86 SP3 (http://myprintscreen.com/s/1ii) does not display on Japanese but with Thai all is well :)
I try to use:
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QString::fromUtf8
tr
trUtf8
QTextCodec::codecForName("UTF-8")->toUnicode
Qt project: http://www74.zippyshare.com/v/39453145/file.html
Help please. I can not understand what to do to make it work.

The solution was simple. The problem with fonts on the user's computer. In my case Qt use by default MS Shell Dlg 2 font. But on user computer he was 'corrupted'. I added this code:
QApplication::setFont(QFontDialog::getFont(0, QApplication::font()));
and continue testing. Some fonts are displayed, and some do not. On different computers have different behavior.
That's why I decided to add to the distribution necessary for me font and install it for QApplication.

Related

Why does Window geometry change when migrating from VS2010 to VS2017?

I have a large Win API C++ Application that i recently moved from Visual Studio 2010 to 2017. Application compiles, links and runs now, but i find that the window borders are about 2 pixels larger than before.
This is a problem as we implemented docking windows long time ago with 100% own code. Although all sizes are retrieved from the OS using GetSystemMetrics etc. this turned out to need some more specific alignment. It took a lot of development time when developing (for Windows 2000) and retargeting later for Windows 7. Furthermore we have some small windows and the thicker frames just waste space.
So i installed the Windows SDK 7.1 and was able after some tweaks to install that. But i am not able to choose 7.1 in the project settings. Typing in that in the project settings results in
error MSB8036: The Windows SDK version 7.1 was not found.
Although I find a directory named:
C:\Program Files\Microsoft SDKs\Windows\v7.1
Also when trying to re-target the Project, the SDK 7.1 is not listed.
I did a lot of googling and found this and that but no substantial answer. msdn is horrible.
Questions (obsolet, see below):
Is it possible to use VC 2017 with Windows 7 SDK? How?
Is there possibly a different way to keep the geometry used with VC2010?
EDIT:
I don't think that this is a duplicate of Dialog border different after porting code from Visual Studio 6 to Visual Studio 2013 although the link is quite helpful. It turned out, that different values are returned for GetSystemMetrics(SM_CYFRAME). So far I do not see a substantial explanation for that. Please see my own answer and comments.
So let me update the question:
Why does the value returned from GetSystemMetrics(SM_CYFRAME) change when upgrading from VC2010 to VC2017?
What is the root cause?
Is it possible to use VC 2017 with Windows 7 SDK? How?
Yes, but I doubt this is the solution to your main problem.
Is there possibly a different way to keep the geometry used with VC2010?
Yes, just change the minimum subsystem version to pre-Vista value, like 5.01 (for Windows XP 32-bit). For some reason, 5.1 will yield the same result too; the resulting EXE would be the same.
When Win32 Subsystem Version is 6.0 or above, there is a behavior change regarding the window border size. Though I am not aware of where Microsoft has documented about this.
If you still have Windows 7, the difference is also obvious when you are using Windows Basic theme, as shown in this screenshot:
Screenshot added by RED SOFT ADAIR:
It turned out that the problem was as described here:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/eaae1445-264d-487f-aba1-52dfc8abdfe4/getsystemmetrics-difference-in-return-value-for-the-same-input?forum=windowssdk
The value returned for GetSystemMetrics(SM_CXFRAME) changed with VS 2013.
In VS2010 (Window 8.1)
GetSystemMetrics(SM_CXFRAME); // 8 pixels
In VS2013 (Window 8.1, same PC)
GetSystemMetrics(SM_CYFRAME); // 4 pixels
In VC2013 and later the same result will be returned using
GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);
My windows still had the same frame size. I miss interpreted the root cause.
Still i do not understand how this can happen. By my understanding GetSystemMetrics is a function of the Windows OS. How can this function behave different when changing the compiler? I guess this IS part of the Windows SDK?
By the way, i found, that i can select "Windows 7.1" as the Platform Toolset, but not for the SDK (as i was thinking).
All this is confusing. Can anybody point out the differences and the junctions between SDK and Toolset?
EDIT:
I made a little sample program to prove this:
#include <windows.h>
#include <stdio.h>
int main(int argc, char *argv)
{
printf("GetSystemMetrics(SM_CXFRAME) returns: %d\n", GetSystemMetrics(SM_CXFRAME));
return 0;
}
Compiling with VC2010 results in "8".
Compiling with VC2017 results in "4".
Even if i choose "dont upgrade" for the SDK when migrating to VC2017.
If you dont believe it - try yourself.
If you have any more insights to that - you're welcome. I give you a 500 points bounty!

How to avoid DPI awareness in a QtApplication for Windows

I have a QtWebKit application and I want to avoid DPI awareness. I tried adding a manifest as documented in MSDN but it only worked in Windows 8.1 (not in Windows 8 and lower versions.)
Inspecting the Qt source code (4.7) I found inside the file qapplication_win.cpp the following snippet:
// Notify Vista and Windows 7 that we support highter DPI settings
ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
if (ptrSetProcessDPIAware)
ptrSetProcessDPIAware();
For more information take a look at the Commit
That said, I don't really know why it's working in Windows 8.1 and more importantly how can I disable this Qt feature... any Macro/Qt API I should use?

Windows Phone: Log to console

Disclaimer: I'm quite new to the MSFT tech world and only started Windows Phone development a month or so ago.
I am unable to figure out how to log information to the Visual Studio Output window from within a C# and C++ (Direct3D) Windows Phone 8 App. Is this possible?
I am building in debug mode, targeting Windows Phone 8, running in the XDE emulator and my development machine is a Windows 8 box with VS2012 Ultimate installed. My App runs fine, my Direct3D scene renders normally, but I can't log anything! This makes tracing code execution difficult and forces me to use breakpoints (which can be overkill in many situations).
I've been searching far and wide and have tried many methods (OutputDebugString being one of them). I can't see anything on MSDN about this - why is this not documented anywhere?
Yep, it's possible to write debug strings from WP8 C++ to the output window in VS2012. I actually have an example of that here.
1) Invoke OutputDebugString from C++.
void Direct3DInterop::MyButtonWasClicked()
{
OutputDebugString(L"Button was clicked!");
}
2) Before running the app make sure to change to the native debugger from the managed debugger in the project's properties.
I believe the methods in System.Diagnostics.Debug (specifically the overloads of WriteLine()) work...although I haven't tried them with C++ apps.

Disabling Main Speech Recognition in SAPI 5.3

I'm coding a program which simply understands basic keywords such as 'left' or 'right'.
It works great, however in order to execute the program, first, i must start Windows Speech Recognition. While my program is running, this 'Windows Speech Recognition' is also processing the commands, and this sometimes shut my program or open a folder.
What i want to do is disable 'Windows Speech Recognition' and still be able to start my program properly.
My code is based on this tutorial: http://msdn.microsoft.com/en-us/vstudio/video/Cc482921
Code: http://download.microsoft.com/download/b/0/1/b01ceff1-5ba9-41e2-ab4f-8b8f4c2f7467/SampleCoding-NativeCoding-ASR2.zip
Also, is there a way to work my program on a Windows editions(such as Windows XP or non-English Windows 7) which does not support speech recognition?
You need to use an inproc instead of a shared recognizer if you only want your application to respond. http://msdn.microsoft.com/en-us/library/ms717071(v=VS.85).aspx may give you some guidance.
Windows XP Tablet edition included a recognizer. Office 2003 included a recognizer that many XP users have installed. I think later updates to XP included a recognizer, but I don't know for sure. I tried to outline the platforms and recognizers as I knew it in https://stackoverflow.com/a/2998963/90236 and in https://stackoverflow.com/a/5861145/90236

Phonon problem in Windows 7 with code compiled in XP

I have some code compiled using Visual Studio 2010 (C++), with Qt for the GUI and Phonon to show some videos.
I compile and run the code in a Windows XP machine and everything works fine. The videos and controls are shown correctly, and the same in other Windows XP machines. But at the moment that I try to use a Windows 7 machine, the video is not shown. Phonon controls are loaded, I can adjust the size of the Phonon VideoWidget but nothing is shown. I am using the SetFile method to indicate the file location and I have also tried (of course, with no luck) with setCurrentSource in the MediaObject (it works, though, in Windows XP).
I have tried different locations of files (absolute/relative) but nothing seems to work. Also, in XP when a video is not found an alert message is shown while in Windows 7 there is no error message, but also no video is shown. If I try to open the videos with other players, they work fine (I tried also with videos with different formats).
Any idea on what can be wrong? Is there something that I am missing with Phonon and Windows 7? Thanks!
When deploying your application to a different computer, make sure you don't forget to copy the Phonon backend. Not just the DLL contained in it (the ds backend for me), but also the directory itself.
That is
-Application Directory
¦-myexe.exe
¦-phonon_backend
¦-phonon_ds94.dll
Furthermore the Phonon backend on Windows (and Mac I think) makes use of the QtOpenGL module. So don't forget to copy this either. It can go inside the application directory.
In any case you could help yourself out a bit by adding a small bit of code that shows (perhaps writes to a file) which mimetypes are available. If it doesn't spit out anything, there is a problem with your backend. (Well, that of your application...)
This is what I had to do when I used Phonon to play video inside my application. Since I only quickly added this some time ago to my application, I'm not 100% sure that this is the only (or even the proper) way to do this, so anyone who has different insights feel free to comment on this.