I am trying to use QVideoFrame library
"#include "
I get no such file or directory message...Any suggestions?
Related
I am using Qt 5.15.1.
If I have a file in in my Qt app's qrc file, is it possible to save the file into application's directory so that I can use that file as a normal file on the file system?
QFile my_file(":/data/file.txt");
QDir my_app_dir(QCoreApplication::applicationDirPath());
in above code, how can I save my_file into my_app_dir?
Environment:
MacOS Catalina
Qt: Commercial version 5.15.1
You just have to copy the content:
QFile my_file(":/data/file.txt");
QDir my_app_dir(QCoreApplication::applicationDirPath());
QString new_path = my_app_dir.absoluteFilePath("file.txt");
if(!my_file.copy(new_path)){
qDebug() << my_file.error() << my_file.errorString();
}
I bought this NFC Shield for my Arduino controller.
https://www.reichelt.de/arduino-shield-nfc-v2-pn532-ard-shd-nfc-v2-p191287.html?PROVID=2788&gclid=Cj0KCQjwnv71BRCOARIsAIkxW9HRIoBqh_ij1c8Kgh8S5l-aCqeCL1c67U8G7OStFVa8SAnW_ZD3V0saAtJxEALw_wcB&&r=1
https://www.seeedstudio.com/NFC-Shield-V2-0.html?utm_source=blog&utm_medium=blog
I downloaded and installed this library as instructed from GitHub
https://github.com/Seeed-Studio/PN532
But when I include the library I get an error:
Code:
include "PN532_SPI.h"
Error message:
ResolveLibrary(PN532/PN532/PN532Interface.h)
In file included from D:\OneDrive\Ardruino\NFC Reader\Seeed\Example Code\2020-05-14\2020-05-14.ino:1:0:
-> candidates: []
C:\Program Files (x86)\Arduino\libraries\PN532_SPI/PN532_SPI.h:6:10: fatal error: PN532/PN532/PN532Interface.h: No such file or directory
include "PN532/PN532/PN532Interface.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
What could be the problem? Please help?
I managed to fix it.
One has to open each and every file in the library and remove the path PN532/PN532_SPI/
So just the file name included must remain, with no path.
So all the .cpp and .h files
Open all .cpp and all .h files in the library and edit them...
Notepad does not format the files correctly, I had to use Visual Studio to edit the .h and .cpp files.
When I try to load a file by the relative path via QFile, gives file not found.
QFile file(fileName);
So I output the current work folder to find the problem like this:
qDebug()<<QDir(".").absolutePath();
Output: /home/username
qDebug()<<qApp->applicationDirPath();
Output: /home/username/program/testApp
The second one is the right path to the work folder. So I think QFile didn't load the file from the work folder but the Linux user folder ~. Why didn't QFile load the file refer to the work folder?
I guess this may be a bug in Raspberry's QtCreator. Because the QFile load file is working well if run in the console.
Use QStandardPaths to store data to your OS paths, in this way you would refer to consistent set of locations when you retrieve the file.
For instance:
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QFile afile;
QString fileName = "/myfile.txt";
path += fileName;
afile.setFileName(path);
I had to mark some of the .xml files for internationalization. I do not use lupdate manually from cmd, instead I put it in the project's .pro file like:
lupdate_only{
SOURCES += $$EXTRA_XML
}
The above code works just fine, but as you noticed I had to put the xml files in SOURCES. As a consequence the .xml files appear in the Sources virtual folder from the left Projects' perspective window, just next to the .cpp files. I find this solution a bit nasty and confusing.
- Project
- - Headers
- - Sources
- - - main.cpp
- - - some.xml //not wanted here
Is there a way to use lupdate, in .pro, on different files such that those files won't appear in the Sources folder? Thanks!
UPDATE
I use Qt Creator 4.0.3
lupdate_only {
SOURCES += $$EXTRA_XML
}
With this conditional statement, lupdate tool sees the .qml files but qmake will ignore it.
I found the solution to my problem, however I think it's a Qt Creator bug. I just moved the lupdate statement with its contents into a .pri file and now the xml files do not appear under the Sources virtual folder. (the .pri file is included in .pro)
I'm working on a project in which all .js and .qml files are stored in the Qt Resource file (.qrc). I've tried to import an external directory in a qml file. The external directory contains other .qml files for different purposes. I don't want to include these external directories into the .qrc file.
I get an error when I add the import path saying:
qrc:\example.qml : cannot find directory
Is there any way to include an external file or directory like this.
Found a solution in the Qt forum, http://qt-project.org/forums/viewthread/7047. For accessing any file outside QRC, use "absolute filepath" of the file.
For example:
In main.cpp file:
QString path = QDir::currentPath(); //path where the exec is present
If your file is in src/file.qml of exec folder, then you can access it like
(path += "/src/file.qml";), now path is the absolute file path for file.qml. You can access it in any of the QRC file.
QQuickView view;
view.rootContext()->setContextProperty("myFile", path);
view.setSource("qrc:/main.qml");
In main.qml file:
Loader
{
id: loadItem
source: myFile
}
Item
{
Component.onCompleted: loadItem.item
}