How to improve graphics quality - qt

First look at the difference:
The top's been created in WPF and the bottom with Qt. All Path Data has been taken from materialdesignicons. For WPF I've taken XAML and for QtQuick SVG. For DropShadow I've specified a value for samples property BUT for svg and rotated Text there's no such property.
Is this the difference between OpenGL/CL/etc. and DirectX or something else? The machine I'm working on has both Intel and NVIDIA! I want my QtQuick app to use NVIDIA to compute efficiently and render properly BUT don't know yet how to set that as well as other necessary options application wide to improve quality.
Here is my QtQuick project. Here I'd added a sample qmlfile earlier, that shows the way I integrated SVGs in my app.
EDIT
This actually improves the quality BUT it still is blurry and not as good as it is in WPF. The rotated text has some pointy edges as well.
With that QSurfaceFormat in main.cpp
int main(int argc, char *argv[])
{
...
QSurfaceFormat format;
format.setSamples(15);
QSurfaceFormat::setDefaultFormat(format);
QQmlApplicationEngine engine;
...
}
I don't have to set samples for DropShadow. How to enable NVIDIA globally?
EDIT
In addition to that I've tried with QSurfaceFormat::OpenVG BUT it complains about the driver and wants 3 DLLs in executable folder as an alternative so I've downloaded those 3 DLL and put those in the output directory BUT it still doesn't work! Here's the error I get:

Related

Dynamic changing of Language in QML view

In my project, there is a language page with four language options. If we change them, entire application language and some images changes. My problem is is there any signal/ callback to switch resources as like in Android or any some other mechanism we should follow for this QML?
To do what you need, first, get familiar with official documentation on Internationalization and Localization with Qt Quick.
Next you need to wrap all strings that should be translated into qsTr. Then, here is simplified code of switching languages:
void Settings::switchToLanguage(const QString &language)
{
if (!m_translator.isEmpty())
QCoreApplication::removeTranslator(&m_translator);
m_translator.load(QStringLiteral(":/language_") + language));
QCoreApplication::installTranslator(&m_translator));
m_engine->retranslate();
}
According to article New in Qt 5.10: Dynamic Language Change in QML.

QTranslator strange behavior

I develop a program on MacOS using QT5.1.1 and I started to use the translation tools in order to translate my program to French (for the moment). I use the code below to install the .qm file :
QApplication a(argc, argv);
QTranslator translator;
translator.load("/path_to_qm_file");
a.installTranslator(&translator);
Using the English file I've got the About and Preferences sub-menu which automatically goes in the Joker menu like that :
And when I load the French file About and Preferences go to the File menu :
How to make Qt understand that I want the first behavior to be the only one it should use ?
This is due to automatic deduction of QAction menu roles. The deduction works for English text, but not for French, especially that you're using the wrong translation of Properties (not the one from Apple's HIG). You need to explicitly set the menu role of your Preferences action to QAction::PreferencesRole - using QAction::setMenuRole. That will solve the problem.

Hide the video created on cvNamedWindow in openCV and display video only on Qt label

I was created a OpenCV console Application on VS2010, and now i was designed a nice GUI using Qt and put the output video/image on Qlabel , project is run fine. but my problem is when i run the program output video is display on both Qlabel and OpenCV GUI called cvNamedWindow/cvShowImage . but i don't want to display video on Opencv cvNamedWindow. when i remove the cvNamedWindow command then video is not display on both Qlabel and opencv gui window. Here is a same question that i want ask: http://answers.opencv.org/question/2914/video-on-label-opencv-qt-hide-cvnamedwindows/
Please help me. Thank you
try qApp->processEvents() after setpixmap and remove cvwaitkey , it's worked for me
(qApp is My QApplication app(argc, argv) )

How do you get System default font settings in Qt?

I am building a desktop app using Qt, my dev machine is win 7 x64 with japanese locale, standard system font is Meiryo. Most of win 7 UI is in this font, though classic/older programs such as ui font customization window itself uses different font which is MS UI Gothic.
This doesn't bother me until I found that QtCreator builds my app with MS UI Gothic in one place, and Meiryo in the other. For example, qlabels, qlineedits, qcombobox all uses MS UI Gothic, but a custom completer with a qtableview i add later uses Meiryo.
I made most of the UI in QtCreator's Designer, and the completer I added in code. If I change all widgets' font to Meiryo in The Designer, then of course the app will use Meiryo therefore look right, but in this case I'd rather Qt pick whatever system's default font automatically for me because win 7 will not be the only platform I'll use this program.
What raised my concern even more is that QApplication::font() returns MS UI Gothic, which is false in my case. Of course I can set app-wide font using QApplication::setFont() but that defeats the whole purpose of having the native look-n-feel without micromanaging fonts.
So my question is,
how do Qt determine system default font and,
if this is a Qt Bug how do I go about getting around it?
how should I use .ui files and still have my UI use default system font in runtime?
Some clarifications and facts I found
I want my app to use system default font for EVERY text.
This discussion said that Designer will add font info regardless whether you want it or not. So Qt will honor this info rather than system default font. At least someone mentioned removing this information manually should make Qt pick system default font in runtime.
In my dev machine QApplication::font() returns WRONG default font. BUT how come a QTableView I add later in code uses RIGHT font? Where did it get this info?
So if I find where QTableView finds this info, I can get it in main, and set it app wide with QApplication::setFont(). Then what's left is manually removing all font info, then HOPEFULLY it will work. But this is like why we use Qt in the first place isn't it?
I can think of two possible solution:
You could pack with your application a font as a resource file, this way all platforms will use that font regardless the current systems default font.
The QFont class has a method called defaultFamily(). Using this you could manually set the default font for your whole QApplication.
An example (main method):
QApplication application(argc, argv);
QFont font;
font.setFamily(font.defaultFamily());
application.setFont(font);
...rest of your code...
Qt will call Windows API SystemParametersInfo to get fonts for QMenu, QMessageBox etc. , and use GetStockObject to get default system font. Some widgets have special font which is different to system default one. I think Qt is doing the right thing, but the default Japanese/Chinese serif font looks bad on HiDPI monitors.
Just use QFont QApplication::font ( const char * className ) to get the right font (Meryo in your case), such as qApp->setFont(QApplication::font("QMenu"))

Application menu disappears when using QApplication in plugin even with qt_mac_set_native_menubar(false)

I am working an Acrobat plugin (SDK Acrobat 8) which uses Qt Widgets. It works fine with Qt 4.3.4. After upgrading to Qt 4.6.4 Carbon, it is no longer possible to see Acrobat's menu if QApplication is instantiated.
int argc = 0;
(void)new QApplication(argc, 0, true);
qt_mac_set_native_menubar(false);
With those 3 lines, the Acrobat menu does not load, neither can it be quit other than with a force quit.
There are no warning messages, everything seems to be working fine, except that is really does not.
Without those 3 lines, acrobat works well as long as not widgets are created (see QApplication doc).
Why?
Thanks for whatever information you may have
Try
qApp->setAttribute(Qt::AA_MacPluginApplication,true);
right after you create the QApplication.

Resources