QPdfWriter not embedding standard fonts properly since Qt 6.0.0 - c++

Since switching to QT 6.0.0 I got problems with QPdfWriter. Every Time I try to print a text, the embedded font couldn't get loaded from various pdf reader (even Adobe reader). I'm as well not getting any errors or anything else on the output.
QPdfWriter writer("C:/Users/GGG/Desktop/lol.pdf");
writer.setResolution(300);
writer.setPageSize(QPageSize(QPageSize::A4));
writer.newPage();
QPainter painter;
painter.begin(&writer);
painter.drawText(600,600,"Hello, this is a test");
painter.end();
My attempts:
Check the doc's and internet -> didn't found anything useful
read out the font (there is one embedded, but faulty)
Change font of QPainter to "Calibri"
check if the font is available with db.hasFamily("Calibri"); (return value = true)
Check graphics card driver -> installed rightly, no updates available .
Rebuild with Qt 5.15.2 (in both cases MinGW64) -> Font is embedded correctly. But gone if I turn back to Qt version 6.0.0
Checked my QT components -> I have installed for Qt 6.0.0: MinGW 8.1.0 64Bit, Sources, Qt 5 compatibility Module, Qt Shader Tools, Qt Debug Information Files.
tried the same with QPrinter which prints Pdf files - same behaviour.
Still no clue what could cause this behavior. Does anyone got the same fault or has a solution?
Information about my system:
Windows 10, 64bit - used fonts are installed
Qt creator 4.14.0 - MinGW64 with Qt 6.0.0

Finally, after research on other forums like forum.qt.io I found out it might be a bug.
There's alredy a bugreport open -> https://bugreports.qt.io/browse/QTBUG-89727
edit: Turned out it was a bug - wich is fixed now. As the bugfixer wrote:
Very nice and subtle bug - the container size was changed from int32_t
to int64_t and the font serialization simply used QByteArray::size()
without a cast.
Bugfix here: https://codereview.qt-project.org/c/qt/qtbase/+/329442

Related

Qt creator 4 cannot find QCamera

I want to use QCamera, but Qt Creator 4.0.1 with Qt 5.6.1 says that such files do not exist, when I'm trying to include it:
#include <QtMultimedia/QCamera>
I've tried it also without the QtMultimedia/ beforehand. And also autocomplition menu.
My System is Debian Testing. This is a C++11 project.
My Project.pro file looks like this:
QT += core gui opengl multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Classifier
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
[..]
I have deleted QT += multimediawidgets, because QT warns, that it is unknown.
Although libqt5multimediawidgets5 is installed. Or do I need more packages for that?
I have tried the following:
I have rerun qmake,
Closed Qt Creator, deleted Project.pro.user and reconfigured the project
Checked if all packages are installed - I hope so. qtmultimedia5-dev qt5base-dev. And libqt5multimediawidgets5 ... Would be to long, to list all, which does not mean, that I have all necessary ones.
Added the options QT_SELECT=qt5 and QTDIR=/usr/share/qt5 qmake --version to the project.pro file. Found it in some stackoverflow answer where a user guessed you could use that to enforce qt5. Because I wasn't sure, if it doesn't use Qt4. But the options do not even get highlighted. But not marked as errors either.
Tried to write 'class QCamera' to my mainwindow.h and include QCamera in the mainwindow.cpp file as seen in a Youtube tutorial
Tried the Camera Example Project, which doesn't work either
Checked, if Qt5 is available in the options menu
As mentioned, I have also Qt4 stuff installed. I have also an old project, which was set up in Windows and uses QCamera. There Qt Creator cannot find it either.
If this does not work anyway on Debian for some reason, what is an alternative -compatible with Qt?
Ubuntu 14.04 with qt5-base, qtcreator and qtmultimedia5-dev recognizes it. And there was an error in the ui mainwindow.h which occurs, if you use a qt4 project with qt5. So it used qt4 on Debian, even though qt5 is installed. But I have no idea how I can enforce qt5 in Qt Creator. So it seems to be a Qt Creator problem. This is actually no direct solution, but it works now (for me). But if anyone knows how to enforce qt5, I would appriciate it. Because Ubuntu is only a workaround

Qt Ctrl++ (Control Plus Plus) Shortcut Not Working in Qt 5.5

I've noticed in Qt 5.5.0 and in Qt Creator 3.4.2 (built on Qt 5.5.0), that Actions attempting to use Ctrl++ are not working. Note that the shortcut works correctly in older versions (for example, Qt Creator 2.7.0 built on Qt 5.0.2).
For example, if I try to increase the font size in QtCreator using Ctrl++, nothing happens. The same is true for the ImageViewer example. (Ctrl++ in the ImageViewer increases the image size, but in 5.5.0, it does not work.)
If I bind increasing the font size to another shortcut in QtCreator (via Tools->Options->Environment->Keyboard), such as Ctrl+Z, it works fine.
I did a little debug by overriding keyPressEvent, and it appears that Ctrl++ is being sucked up earlier in the dispatch, but I am having trouble figuring out exactly where.
My questions are:
Is this a bug?
If not, does anyone have any advice on how to see how the key is being dispatched?
This is a confirmed bug in Qt 5.5.0 and appears to be fixed in the latest builds.
There is more information here:
https://bugreports.qt.io/browse/QTBUG-47701

Cannot Connect to QML Emluation Layer (QML Puppet)

I just made the fresh QT installation and when I create empty QT Quick project or open any of existing QT Quick examples, my QML designer doesn't work. It shows "Cannot Connect to QML Emluation Layer (QML Puppet)" error.
I tried to reinstall QT, reboot, installed additional QT kit versions and tried to switch between 32bit/64bit default/opengl versions of the kit and nothing seems to work for me. I was able to successfully run the designer ONCE, and after I closed it and tried to re-open the file it stopped working again. I also tried to search, but didn't find any solution. I also tried to ask on QT forums, but didn't receive any answer.
My system is Windows 7, with Visual Studio 2013 installed. Thanks for your help!
Do this:
Go to QT Creator Preferences (Menu Bar | Tools > Options)
Select QT Quick Option (Options headings - left side).
Click the QT Quick Designer tab.
Under QML Emulation Layer grouping, select "Use QML Emulation Layer that is built with selected QT".
No need to choose a path,
And click OK.
It will rebuild your designer view.
Worked for me.
Possibly related to this bug. Just try this workaround: in the Options
dialog go to “Qt Quick / Qt Quick Designer / QML Emulation Layer” and
disable the checkbox “Always use the QML emulation layer prived by Qt
Creator”. That will cause a rebuild of the emulation layer with the
used Qt version in the current project. That layer does not crash.
This workaround only works with Desktop Kits. – BaCaRoZzo Mar 30
This worked for me on Ubuntu 14.04.
Go to Tools->Options->Qt Quick.
In QML Emulation Layer, make sure
the path is correct for "Use fallback QML emulation layer".
Since I was reinstalling Qt, the new installation had the old path of Qt which gave rise to this issue.
If failed anyway, use "Qt Design studio" instead and build it again, it worked for me.
I recommend to uninstall Qt first and then reinstall it with "Qt Design Studio" box checked.
On Ubuntu 20 LTS, you can run it on: /home/Qt/Tools/QtDesignStudio/bin/qtdesignstudio
Good luck.

How to connect QT with VLC player

In my QT GUI application I need playback some video files. I tried the MediaPlayer component (qtmultimedia 5.0), but it cannot read the video containers (mp4/mkv) that I'm using, which VLC player runs without any problem. So I found an library called vlc-qt (http://projects.tano.si/vlc-qt) and downloaded the windows binaries (which seem to be compiled using MSVC 11.0), but it fails to link on QT Creator MinGW (it shows 16 lines of undefined reference), maybe because vlc-qt is compiled with a different compiler than the one used to build the QT app.
I can't find any working references or documentation on this topic, so does anybody know how can I make this?
More details:
Windows 8.1 x64
QT Creator 3.0.1 | QT 5.2.1
vlc-qt 0.9.0
C++
Thank you.
The library is compiled using MSVC so it can not be liked to your application with a MinGW compiler. You can get the code from Here and compile it with MinGW compiler. After that you can link it to your app.
You can download and install CMake from Here. Next open the file named "CMakeLists.txt" from the root of the VLC_Qt source code with Qt Creator. Click "Next" and then after selecting the desired Generator click "Run CMake". WHen everything completes click finish. Now you can build the entire VLC-Qt with Qt Creator.

Qt is unable to detect printers on Windows

I'm using Qt for a project (Qt 5.0.2, precompiled and downloaded from qt-project.org) on Windows 7 (32-bit) and I'm having trouble trying to print a document.
qDebug() << QPrinterInfo::availablePrinters().size(); // 0
I'm able to print as PDF and I tested the same executable in other computers, it works just well. I do have printers installed and I can print normally from any other program such as notepad or Word. Any clue on why is it returning an empty list? I can't find this behavior documented anywhere, is this a Qt bug?
When you deploy your Qt application, you should put
[your Qt application]\printsupport\windowsprintersupport.dll
The library windowsprintersupport.dll should be taken from
[Qt path]\[platform]\plugins\printsupport
P.S. The first answer is almost correct, except path's names.
May be your application cannot find plugins which allow printing
facilities (printingsupport directory must be in execution directory
from qt the bin\plugins directory).
This answer is moved from AnatolyS' comment.