Virtual Keyboard qt how to put it in azerty - qt

I want to change the VirtualKeyboard to [azerty].
I tried to put VirtualKeyboardSettings.locale = "fr_FR" but it doesn't work.
I also tried to put CONFIG += lang-fr_FR in the .pro file like it says in the Qt documentation but still doesn't work.

I'm not sure what platform you are targeting, however Qt typically picks up on the runtime platform's locale setting, and applies this automatically wherever localisation is required, e.g. controls, dates, times, numbers etc. I would expect this to include the virtual keyboard.
However, if necessary you should be able to override the locale application-wide using QLocale::setDefault. See the documentation here.
If this doesn't work, please add some more information to your question so we can get a better idea of the problem.

Related

Can I globally switch to native text rendering in Qt Quick Controls 2?

I would like to use native rendering for all the text in my application. For each Text, Label, etc. element I can do this
Text {
renderType: Text.NativeRendering
}
to trigger native rendering. I can also use the software renderer for the whole application:
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
However due to some bugs with the software renderer and some performance issues, I would like to avoid that.
Is there a global switch to change the render type?
Since Qt 5.7, you can change the default Qt Quick text render type, but unfortunately only at build time. In order to change the default, you would have to rebuild libQt5Quick.so with QT_QUICK_DEFAULT_TEXT_RENDER_TYPE set to NativeRendering. For more details, see https://codereview.qt-project.org/#/c/121748/ .
If you have installed Qt using an installer from qt.io, install the source packages using the maintenance tool if you already haven't done so, navigate to qtdeclarative/src/quick, run qmake with the define, and build. Something along the lines:
cd path/to/Qt/Sources/5.8/qtdeclarative/src/quick
# NOTE: make sure to run qmake from the same/correct Qt installation
path/to/Qt/5.8/<spec>/qmake "DEFINES+=QT_QUICK_DEFAULT_TEXT_RENDER_TYPE=NativeRendering"
make -jN
If you have a self-built Qt installation, invoke make clean (or if you want to save time, just delete qquicktext*.o) before make to rebuild the library.
EDIT: Since Qt 5.10, it is also possible to specify the default text render type in C++ via QQuickWindow::setTextRenderType(). Just notice to set it before loading the QML content.
The environment variable QML_DISABLE_DISTANCEFIELD controls this.
If you put
qputenv("QML_DISABLE_DISTANCEFIELD", "1");
at the beginning of your main, you will get a nice and sharp text rendering everywhere.
Source: http://www.kdab.com/~thomas/stuff/distancefield.html
Add this line first in c++ main function : QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);

How to obtain entire Qt StyleSheet for QMacStyle

Is it possible to obtain a text file of the entire Qt5 StyleSheet for QMacStyle (or its equivalent QProxyStyle that's apparently used in Qt5)?
I'm hoping to get a list of all the property:value pairs ('background-color', 'border-radius', 'margin-top', 'padding', etc.), along with their default settings, that are used for each of the common widgets (QPushButton, QTabBar, etc.).
Qt5 on Mac OSX looks great due to all of the native-looking widgets (see e.g. Macintosh Style Widget Gallery). I'd like to perform some surgical replacements of a number of style properties in my application, but otherwise keep the native look-and-feel. (An alternate take on the problem, or at least on the same end goal, is represented in my related question How to override just one property:value pair in Qt StyleSheet.)
If I knew the entire Qt StyleSheet equivalent for a QTabBar or QPushButton, I could reconstruct the native look-and-feel in my own invocations of widget->setStyleSheet(), adding in my few necessary tweaks.
I've searched the entire Qt5.4.0 directory hoping to find a *.qss file representing OSX style, but to no avail (I found the promisingly named examples/widgets/widgets/stylesheet/qss/default.qss, however all it says inside is //* empty stylesheet *//). I've exhausted my ideas running grep on the full Qt5 source directory, including in qt-everywhere-enterprise-src-5.4.0/qtbase/src/widgets/styles/, which may indeed contain the details but not in very digestible form).
Thanks --
QMacStyle is a QStyle subclass that is using Apple's HITheme for drawing (look for the files qmacstyle_mac* to see the implementation), so there is no stylesheet to obtain.

How can I get a QFileDialog to prompt for overwrite?

I have a QDialog that opens a QFileDialog like so:
QFileDialog fd(this);
fd.setFileMode(QFileDialog::AnyFile);
if (fd.exec()) {
// save data to a file
}
Unfortunately, the default behavior doesn't seem to be quite so default, and the file dialog doesn't prompt me about overwriting if I select a file that already exists. Calling setConfirmOverwrite(true) or setOption(QFileDialog::DontConfirmOverwrite, false) first doesn't help either. I've tested this both on Qt 4.7.3 and 4.7.4 on both Ubuntu 11.04 and Windows XP.
I looked around and found this bug report. QFileDialog::getSaveFileName() had this issue, but it was specific to Maemo and fixed well before Qt 4.7.3 came out. If I use that method in my application it works just fine, I get prompted about overwriting the file. (I don't want to use getSaveFileName() for unrelated reasons.)
I can't find anyone else complaining about this not working for them. Am I doing something wrong, or is this a bug? I think it might be due to the dialog not knowing whether it's just a simple Open dialog where prompting wouldn't make sense, but I don't see a way to tell it it's a Save dialog (beyond setting the confirm-overwrite option, which fails), and the documentation does say it should prompt by default.
You should also be sure that the dialog is in save mode, as it will not think you are overwriting a file when in open mode. You can do this by calling fd.setAcceptMode(QFileDialog::AcceptSave); in your code example. See QFileDialog::acceptMode.

How to make Qt Creator to show pop-up documentation of my functions the same way it does for the functions from the Qt library?

When you place the mouse pointer over any Qt function/class it shows a pop-up with short description of what it does, taken from the docs in the comment above the function/class.
For my functions/classes I have documentation in the doxygen format:
/**
Returns foo
*/
QString getFoo() {
return "foo";
}
When this function is used, I want to view the same type of pop-up with my docs when the mouse pointer is over the function name.
Is it possible to do that with Qt Creator?
Unfortunately it's not possible for Qt Creator (as of the recently release 2.4) to pick up the tags on-the-fly. However, what might work is to let doxygen run, and tell it to create qch files. If you register the created qch file, you should get mouse-over and even a proper help file. See http://www.ogre3d.org/tikiwiki/Integrating+API+documentation+into+Qt+Creator+Help for how Ogre3D does it. YMMV if that's worth it for a fast-changing project. It's certainly a good idea for a (semi-)stable library.
Relevant bug report: https://bugreports.qt.io/browse/QTCREATORBUG-4557
Qt Creator requires the generated docs to have some special markers in order to retrieve the tooltip text. I couldn't find a way to insert these markers with Doxygen so I've created a simple script to do it:
https://github.com/mmmarcos/doxygen2qtcreator
It's not bulletproof but it allows us to integrate our classes and methods briefs into Qt Creator tooltips.

QVision Widget Error upon compile

Only one error to go until I get to use this for my research!
Warning: Z-order assignment: " is not a valid widget.
FILE: qvvideoreaderblockwidget.ui
There's no line number that came with it. I tried finding but, failed to see an open-ended part.
What should I do to correctly compile this library?
Edit the ui file outside of Qt Creator. Delete the rows with 'zorder' tags. Then open in Qt Creator and compile again. It worked for me then perfectly, the warning did not appear any more.
OK, I had this, and it irked me too. I don't know what happened to cause this, but it is not serious. I suppose that breaking and remaking all the layouts might fix it. Other frameworks tend toward a lot of warnings, but tho I'm new to Qt, not a one yet. I went in another editor, and removed a line that said (as best I can remember):
<z-order>verticalSpacer</z-order>
which was among a lot of other lines which also were z-order tags. I deleted the line with this tag, and rebuilt all. Problem gone. Interestingly enough, all of the z-order tags had vanished from my file when I looked at it next. It must be a bug, but evidently one of little consequence; except those who hate to see the serene beauty of Qt spoiled.
Does the ui-file qvvideoreaderblockwidget.ui contain "Promoted widgets"? If so, use the "Promoted widgets" dialog of the (Qt4-) designer for ensuring that the header of the promoted widget-class is declared as "global include".
In case the custom widget class is named "MyWidget" and the header is named "mywidget.h" and the member widget shall be named "myWidget", the uic will generate the code of the ui-class as follows:
#include <mywidget.h>
class qvvideoreaderblockwidget
{
public:
MyWidget* myWidget;
// ...
};
It happened to me when I deleted a fairly large chunk of stuff in the designer. Investigation showed that the designer had failed to remove a zorder tag relating to the widget I deleted (which, incidentally contained a bunch of other widgets).
Deleting the line as suggested cleared the problem. If you do have a load of zorder tags you probably need to be careful to just delete the one that relates to the deleted item.
I had the same problem, and deleting the .exe file from the output folder (debug or release) before run/compile the source, solved the problem.
This problem arises due to a (presently) unfixed bug in Qt Creator's undo / delete mechanism.
The solution until the bug is fixed is to:
Close the .ui file in Qt Designer
Open the .ui file in an external editor
Delete the <zorder> line(s) that apply to the element with the problem. For example:
<zorder>groupBox_2</zorder>
Save the file
Re-open the file in Qt Designer
Re-compile in Qt

Resources