Why is QPdfDocument not found?
During installation I selected Additional Libraries "Qt PDF" and "Qt WebEngine". Then I wrote this code in CMake:
find_package(Qt6 REQUIRED COMPONENTS Pdf)
target_link_libraries(mytarget Qt6::Pdf)
Then I got the message:
"Found package configuration file: C:/Qt/6.3.1/mingw_64/lib/cmake/Qt6/Qt6Config.cmake but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT FOUND. Reason given by package: Failed to find Qt component "Pdf". Expected Config file at "C:/Qt/6.3.1/mingw_64/lib/cmake/Qt6Pdf/Qt6PdfConfig.cmake" does NOT exist"
#include <QApplication>
#include <QPdfDocument> //not found
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
Dont know the qt version. Community Edition? Maybe this helps:
QtPDF Build Instructions
Related
I'm trying to build a small Qt6 application on a Docker container. It is running on Ubuntu:22.04. I have installed the qt6-base-dev package. Here is my small test app:
#include <QApplication>
#include <QWidget>
#include <iostream>
int main(int argc, char argv)
{
QApplication app(argc, argv);
QWidget widget;
widget.setFixedSize(400, 400);
QString helloString = "Hello from " + qgetenv("USER") + "!";
widget.setWindowTitle(helloString);
widget.show();
return QApplication::exec();
}
And here is my CMakeList.txt:
cmake_minimum_required(VERSION 3.0)
project(testproj)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
add_executable(testproj main.cpp)
target_link_libraries(testproj PRIVATE Qt6::Widgets)
But when my cmake is configuring this error appear:
CMake Error at CMakeLists.txt:5 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:
Failed to find Qt component "Widgets".
Expected Config file at
"/usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists
The /usr/lib/x86_64-linux-gnu/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake is existing.
I couldn't find anything online about this problem.
I have installed libgl1-mesa-dev and libglvnd-dev and it worked perfectly !
I am following this qt tutorial.
helloworld.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = helloworld
TEMPLATE = app
SOURCES += main.cpp
main.cpp
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton button ("Hello world!");
button.show();
return a.exec(); // .exec starts QApplication and related GUI, this line starts 'event loop'
}
Type the following shell commands to build the program.
qmake -project
Error:
PS E:\QT_tut\Tut_cmake_1\nSR> qmake -project
Project ERROR: Cannot run compiler 'cl'. Output:
===================
===================
Maybe you forgot to setup the environment?
PS E:\QT_tut\Tut_cmake_1\nSR>
QT: 5.12.12
VS: 2019
But, I can run this program using QT GUI.
I currently have a terribly annoying problem while developing programs using Qt and Qt Creator. Whenever I try using qDebug() with a QCoreApplication or QApplication instantiated before using qDebug(), there isn't any output, whether I run the program in Qt Creator or from a normal shell(I'm using Fedora Linux btw). For example, even the following simple code fails:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "TestOutput!" << endl;
}
Does anybody know what to do about this problem?
Thanks in advance,
Marius
For better formatting, I add this new solution, marius still found it himself in this bugzilla.
Edit ~/.config/QtProject/qtlogging.ini and add:
[Rules]
*.debug=true
qt.qpa.input*.debug=false
The last line is to disable spammy debug logging for moved mouse messages.
Docs around this can be found here: http://doc.qt.io/qt-5/qloggingcategory.html#details
It can be configured in many ways. Few useful examples:
by env variable(cmd):
$ export QT_LOGGING_RULES="*.debug=true" ./app
by env variable(export):
$ QT_LOGGING_RULES="*.debug=true"
$ ./app
or in code:
#include <QCoreApplication>
#include <QLoggingCategory>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QLoggingCategory::setFilterRules("*.debug=true");
qDebug() << "Debugging;
a.exit();
}
OK, I found out what the problem was, it was indeed Fedora, but it's the new standard configuration. See here:
https://forum.qt.io/topic/54820/
This one help for me (In user bashrc file):
export QT_LOGGING_DEBUG=1
I've install Netbeans 7.2 and Qt 5 on Windows7. Everything compiles fine.
But recently when I create a Qt form and try to use it in this way:
New Project > C/C++ Qt Application > Finish
Right click on new Qt project > New > Qt Form > Finish
After saving ui file in Designer
This error appears:
newForm.h:11:24: fatal error: ui_newForm.h: No such file or directory
The content of main.cpp is :
#include <QGuiApplication>
#include "newForm.h"
int main(int argc, char *argv[])
{
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
QGuiApplication app(argc, argv);
// create and show your widgets here
return app.exec();
}
I tried to manually create ui_xwz.h file and add it to my project. But I want it work automatically as same as before. How can I solve it?
I have a ridiculous solution, Maybe we should report it as a bug to Netbeans or Qt.
Go and active QtSVG and QtXml modules of your project and rebuild it. I tested this way and the problem vanished.
I jsut installed Qt 4.7.2 and I'm trying to use the QLibraryInfo class. My problem is that QLibraryInfo::location(QLibraryInfo::PrefixPath) always returns C:\work3\qt-4.7-vs2010-x86 which doesn't exist on my generation machine (should be C:\Qt\qt-4.7.2).
According to the documentation I tried to create a qt.conf file alongside my program, but the problem still remains. Here's its content:
[Paths]
Prefix=C:/Qt/qt-4.7.2/
For now I used a symlink to bypass the issue, but I'd like to know if there's a proper solution.
Thanks.
EDIT
Here's the program using the QLibraryInfo:
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv); //< added after Piotr's suggestion
QFile outf("qtdirs.out");
if (!outf.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text))
return 1;
QTextStream out(&outf);
out << QLibraryInfo::location(QLibraryInfo::PrefixPath) << '\n';
out << QLibraryInfo::location(QLibraryInfo::HeadersPath) << '\n';
...
}
A QCoreApplication must be created because that is how the QLibraryInfo is able to determine the application directory (QCoreApplication::applicationDirPath()) from which to load the qt.conf file. Alternatively, the qt.conf can be built into the application as a resource with the path ":/qt/etc/qt.conf".