qtreeviewprivate.h : no such file - c++

I have a problem with Qt 5.5 and QTreeView. qtreeview.h (Yes, it's from Qt folder) has compiler error:
fatal error: QTreeViewPrivate: No such file or directory.
My Qt5.5 library doesn't know about QTreeViewPrivate, but qtreeview.h needs it. Every simple code like this QTreeWidget *fileList = new QTreeWidget(); or else linked to QTreeView makes my complier angry! Maybe it's some bug? Where is QTreeViewPrivate ?

Check if you added the correct library to your project file:
QT += widgets
See documentation: http://doc.qt.io/qt-5/qtreeview.html

Check if you added the correct Qt folder path to your project.
In project properties, c/c++ general libraries.

Well, I found the solution. To use QTableWidget that no need QTableViewPrivate's header I edit qtableview.h in my Qt folder, I replased #include <QTreeViewPrivate> to class QTreeViewPrivate;. Now code works fine!

Related

error use of undeclared identifier 'mainwindow' semantic issue in QtCreator

I just create new Qt Widgets Application. I open the mainwindow.cpp and it's like mainwindow.cpp doesnt see the "mainwindow.h" while i was on editor. But compiler works fine. How do i fix this semantic issues?
I added 'QT += widgets' to .pro file. It doesnt work.
These are actually default files.
--mainwindow.h--
--mainwindow.cpp--
I fixed this bug by unchecking Help/Plugins/C++/ClangCodeModel and restart QtCreator.

Cannot open source file "ui_QtGuiApplication.h" in default Qt project

I installed the latest QT version and the QT tool for Visual Studio. When creating a new GUI project in Qt, the default program should create an empty window, but it seems that I'm getting an E1696 error in Visual Studio Community: "cannot open source file "ui_QtGuiApplication4.h".
The error takes place in the default header class created for the project:
#include <QtWidgets/QMainWindow>
#include "ui_QtGuiApplication4.h"
class QtGuiApplication4 : public QMainWindow
{
Q_OBJECT
public:
QtGuiApplication4(QWidget *parent = Q_NULLPTR);
private:
Ui::QtGuiApplication4Class ui;
};
The Ui tag is also not recognized.
I added the additional include directiories for the QT path and I tried switching up between the 64bit and 32bit version of QT, but I'm getting the same error.
Any help would be appreciated!
The ui_<YourClass>.h header file is a file that only gets generated for you when you compile your project. Qt's User Interface Compiler uic will read your .ui file(s) and create the corresponding ui_ headers before the actual C++ compiler is invoked.
So you have to give it at least one compile run to generate the file. Then your IDE should be smart enough to find it.
FYI: Using QtCreator 4.12 you won't even have to compile. The clang backend process will generate the file in a temp folder somewhere probably to give you the proper code inspections (regarding code completion and so on). As I read from your question you're using Visual Studio which doesn't seem to do that.

Newbie help for Visual C++ project references

I know next to nothing about C++, except that I have a missing to take someone else's C++ library and wrap it for use by C#. I found a few posts about how to do it, and I'm making my way there, bit by bit. But I've hit a wall at this point.
According to this post I'm supposed to create a new managed C++ project. This I have done, and I added a reference to the project I'm supposed to be wrapping. So my code looks like this:
#include "stdafx.h"
#include "DrmWrapper.h"
#include "../OtherLibrary/drm/adept/src/adept_provider.h"
DrmWrapper::DrmWrapper(dpdrm::DRMProcessorClient * client, dpdev::Device * device)
{
adept::DRMProviderImpl * provider = new adept::DRMProviderImpl();
drm_processor_ = provider->createDRMProcessor(client, device);
}
unsigned DrmWrapper::initSignInWorkflow(unsigned workflows, const dp::String& authProvider, const dp::String& username,
const dp::String& password)
{
return drm_processor_->initSignInWorkflow(workflows, authProvider, username, password);
}
All looks good. But when I try compile my wrapper project, I get an error:
d:\src\drm-wrapper\OtherLibrary\drm\adept\src\adept_provider.h(26): fatal error C1083: Cannot open include file: 'dp_all.h': No such file or directory
Eh...whut? I'm not trying to compile the adept library. That already built fine by itself. I just want to compile my own wrapper project. And the dp_all.h file does exist, in the same folder as adept_provider.h.
Clearly there's some paradigm shift I'm not making from C# to C++; it seems like the code is being rebuilt as if the referenced project's source file were in my project folder.
What's the secret switch to get this working?
You should add ../OtherLibrary/drm/adept/src as one of the places where your project looks for header files (in C++/General/Additional Include Directories).
You should change #include "../OtherLibrary/drm/adept/src/adept_provider.h" to #include "adept_provider.h".
What's happening is that the compiler is looking for dp_all.h relative to your project not to the other project. Compilation is not totally separate in C++, headers files are shared between projects and are recompiled in each project where they are used.

How to include QwebEngineView without getting an error

Question is simple; I get an error "Unknown module QWebEngineView" when I write the line Qt += QWebEngineView in .pro file.
How to get rid of this ?
I have tried many solutions but still got the error when compiling. If you got a solution please explain it entirely step by step.
I run Qt 5.10.1 with Ming32 5.30.
Try to use msys2 project that contains mingw64 with patches for qt5.
Write in your .pro file
QT += webenginewidgets
Add
#include <QWebEngineView>
in file that will use QWebEngineView class

How to run a simple cpp file that requires QT?

I have QT 5.1.1 installed on my machine, but I'm having some troubles using it. I'm trying to run the following simple program that requires QT:
//Playing Video
#include "cv.h"
#include "opencv2\objdetect\objdetect.hpp"
#include "opencv2\core\core.hpp"
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\features2d\features2d.hpp"
#include "opencv2\calib3d\calib3d.hpp"
#include "opencv2\nonfree\nonfree.hpp"
#include "highgui.h"
#include <openbr\openbr_plugin.h>
using namespace cv;
static void printTemplate(const br::Template &t)
{
const QPoint firstEye = t.file.get<QPoint>("Affine_0");
const QPoint secondEye = t.file.get<QPoint>("Affine_1");
printf("%s eyes: (%d, %d) (%d, %d)\n", qPrintable(t.file.fileName()), firstEye.x(), firstEye.y(), secondEye.x(), secondEye.y());
}
int main(int argc, char *argv[])
{
br::Context::initialize(argc, argv);
// Retrieve classes for enrolling and comparing templates using the FaceRecognition algorithm
QSharedPointer<br::Transform> transform = br::Transform::fromAlgorithm("FaceRecognition");
QSharedPointer<br::Distance> distance = br::Distance::fromAlgorithm("FaceRecognition");
// Initialize templates
br::Template queryA("../data/MEDS/img/S354-01-t10_01.jpg");
br::Template queryB("../data/MEDS/img/S382-08-t10_01.jpg");
br::Template target("../data/MEDS/img/S354-02-t10_01.jpg");
// Enroll templates
queryA >> *transform;
queryB >> *transform;
target >> *transform;
printTemplate(queryA);
printTemplate(queryB);
printTemplate(target);
// Compare templates
float comparisonA = distance->compare(target, queryA);
float comparisonB = distance->compare(target, queryB);
// Scores range from 0 to 1 and represent match probability
printf("Genuine match score: %.3f\n", comparisonA);
printf("Impostor match score: %.3f\n", comparisonB);
br::Context::finalize();
return 0;
}
It also requires OpenCV 2.4.6.1 and OpenBR, but that's not the problem.
All the definitions (variables and functions) in the above code that are related to QT are undefined. I've tried to find the relevant h files in QT folder and to include them, but that did not succeed since I couldn't fine qtcore.h (but a different file named qtcore with lot's of includes that I don't now how to use). I've tried to add QT "include" directory under "additional include directories" in the project properties but that didn't work either. I've also tried to add QT "lib" folder under "additional library directories" but that also did not work.
Basically, I tried everything I could think of. Can someone please explain how to I use those QT definitions? I'm really stuck and I could use any help given.
Thanks,
Gil.
(Optional) Update to Qt 5.2.
Start Qt Creator.
Create a new Qt Widgets Application project. You can give the class/files random names, it doesn't matter. Uncheck the "generate form" option, as you don't need any forms.
Remove all the files other than main.cpp from the project. You do this by right-clicking on them in the project tree on the left and choosing Remove File.
Copy-paste your code into main cpp. Make sure you completely replace main.cpp's contents, the default contents shouldn't be there anymore.
Add the opencv library to the project. Right-click on the project's root, select "Add Library", and go from there.
Re-run qmake by right-clicking on the project root and selecting "Run qmake".
Build and run the project by pressing Ctrl-R (Cmd-R on mac).
Qt uses a (non-standard) custom toolchain that has to run before the Qt-dependent code can be compiled. I've never tried using Qt outside of QtCreator, but if you really need Qt I'd suggest you use the QtCreator IDE; if you're not using it already of course. It's a very decent IDE, even for non-Qt projects.
Also, if you haven't done so already, make sure the Qt SDK is installed; the headers alone are not enough. QtCreator by itself is also not enough, you'll need the SDK. If you don't feel like doing so, my suggestion would be to look at Poco. It's not a 1:1 replacement for Qt, but a very mature framework nevertheless.