The MarbleAbstractPresenter class is present in the api(https://api.kde.org/4.x-api/kdeedu-apidocs/marble/html/classMarble_1_1MarbleAbstractPresenter.html) as well as the current source code(https://github.com/KDE/marble/blob/master/src/lib/marble/MarbleAbstractPresenter.h), but cannot be added to the Qt project.
#include <marble/MarbleWidgetInputHandler.h> //Works
#include <marble/MarbleAbstractPresenter.h> //No Valid Expression
The MarbleAbstractPresenter file is not in the /export/include/marble/ directory like most of the other .h files. Is there a way to add this file so that it can be read by Qt or is there a different way to create an MarbleAbstractPresenter so that a command like this can run?
MarbleWidgetInputHandler *a = new MyInputHandler(new MarbleAbstractPresenter(new MarbleMap()), mapWidget);
Related
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.
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.
I created my first OMNeT++/veins project, but can’t start the simulation.
Can you help me?
I would like to change my question - is there a simple way to create a project, similar to RSUExampleScenario of veins, not under veins/examples/myfolder, but in a separate project and workspace? And what steps must I do for it?
I wanted to create a project similar to RSUExampleScenario from veins, but with other scenario and using other OMNeT++ modules. As I created my project under veins/examples/myfolder, and put my new .ned files under veins structure, it worked fine.
Now I created new project, including folders with .ned and c++/h files, like folder connection (Connection.ned, Connection.cc, Connection.h, package.ned) and folder node (CloudVehicleScenarioMessage.ned, Cloud.ned) and simulation folder cloudvehiclehi (omnetpp.ini).
When I start a simulation I receive the error:
Error in module (cCompoundModule) CloudVehicleScenarioMessage (id=1) during network setup: Class "Connection" not found -- perhaps its code was not linked in, or the class wasn't registered with Register_Class(), or in the case of modules and channels, with Define_Module()/Define_Channel().
I guess the NED files are loaded, but the classes in c++ files cannot be found, though I used Define_Module. Cloud is just a compound module, without any own c++ implementations, it creates no problems. Connection is a simple module, referring to class Connection.cc, where Define_Module() is called and causes the error while loading.
All my folders, like node or connection are included, as I can see under Project->Properties->Paths and Symbols->Includes.
I already tried to rebuild OMNeT++ (as told here https://www.linkedin.com/grp/post/3801609-234767834) and to define namespaces for my classes (as told here Problem in defining a module in omnetpp), but it didn’t help.
I proved my makefile and the folders were linked in (as told here https://groups.google.com/forum/#!topic/omnetpp/Cl48hVgkbQ0).
CloudVehicleScenarioMessage.ned is my network in omnetpp.ini.
nodes/CloudVehicleScenarioMessage.ned:
package cloudbasedcsw.nodes;
import cloudbasedcsw.nodes.ScenarioMobility;
import cloudbasedcsw.nodes.Cloud;
import cloudbasedcsw.connection.Connection;
network CloudVehicleScenarioMessage extends ScenarioMobility
{
#display("bgb=540,555");
submodules:
cloud[1]: Cloud {
#display("p=150,140;b=10,10,oval");
}
con: Connection {
#display("p=200,40;b=10,10,oval");
}
}
ned file of module Connection:
connection/Connection.ned
package cloudbasedcsw.connection;
simple Connection{
#class(CloudBasedCSW::Connection);
}
Class Connection, which can not be found:
connection/Connection.cc
#include <Connection.h>
#include <VehicleListener.h>
#include <iostream>
using CloudBasedCSW::Connection;
Define_Module(CloudBasedCSW::Connection);
void Connection::initialize(int stage){
}
void Connection::connectToCloud(cModule* node){
}
void Connection::disconnectFromCloud(cModule* node){
}
Connection.h
#ifndef CONNECTION_H_
#define CONNECTION_H_
#include <omnetpp.h>
namespace CloudBasedCSW{
class Connection: public cSimpleModule{
public:
cModule* scenario;
void connectToCloud(cModule* node);
void disconnectFromCloud(cModule* node);
protected:
virtual void initialize(int stage);
private:
cModule* cloud;
int currentId;
int gateCloudInId;
int gateCloudOutId;
};
}
#endif /* CONNECTION_H_ */
I guess that your class Connection is in CloudBasedCSW C++ namespace. Therefore in Connection.ned you should change #class(Connection); to #class(CloudBasedCSW::Connection);.
I managed to create a new project and run it, without this error. So, I will share my tutorial.
How to create a OMNeT++ project, which uses veins.
Create omnet++ project myproject File->new->OMNeT project->Empty project with 'src' and 'simulations' folders
Veins must be imported into the workspace in order to use it: Import-> Existing projects into workspace->
Add veins to Project->Properties->Project References
Put your .ned and c++/h files in folder src
Put omnetpp.ini and all sumo configuration files in folder simulations
Create run configuration simulation, with working directory myproject/simulations and Simulation->Executable->Other: with exe file from /myproject/src/myproject
Remark: Don't use namespaces in your c++ files, corresponding to .ned files, because the classes in c++ files would not be found (
Error in module (cCompoundModule) CloudVehicleScenarioMessage (id=1) during network setup: Class "vehicle" not found ).
For Example you have vehicle.ned and vehicle.cc. vehicle.cc
includes a class mynamespace::vehicle. vehicle.ned wouldn't know that vehicle lies under namespace mynamespace. Only if a class is defined in ned file via #class(mynamespace::vehicle), it can be found.
A easy way to correct this error is copying the .cc or all c++ files into a veins/src/ folder. Using this technique you compiler recognize you class.
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.
I'm trying to create a simple GUI application (so far) in Qt with C++ using the MinGW compiler. However, the compiler is informing me that I have a multiple definition of 'WiimoteScouter::WiimoteScouter(QWidget*)' on line 4 of wiimotescouter.cpp. I am using a check to make sure the header isn't included multiple times, but apparently it's not working, and I'm not sure why.
Here's the header file:
#ifndef WIIMOTESCOUTER_H
#define WIIMOTESCOUTER_H
#include <QWidget>
class QLabel;
class QLineEdit;
class QTextEdit;
class WiimoteScouter : public QWidget
{
Q_OBJECT
public:
WiimoteScouter(QWidget *parent = 0);
private:
QLineEdit *eventLine;
};
#endif // WIIMOTESCOUTER_H
And here's the cpp file:
#include <QtGui>
#include "wiimotescouter.h"
WiimoteScouter::WiimoteScouter(QWidget *parent) :
QWidget(parent)
{
QLabel *eventLabel = new QLabel(tr("Event:"));
eventLine = new QLineEdit;
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(eventLabel, 0, 0);
mainLayout->addWidget(eventLine, 0, 1);
setLayout(mainLayout);
setWindowTitle(tr("Wiimote Alliance Scouter"));
}
Lastly, the main.cpp:
#include <QtGui>
#include "wiimotescouter.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
WiimoteScouter wiimoteScouter;
wiimoteScouter.show();
return app.exec();
}
I've seen this happen before when a source file got duplicated in the project (.pro or .pri) file. Check all of the "SOURCES =" and "SOURCES +=" lines in your project file and make sure the cpp file is not in there more than once.
I don't use MinGW but this sounds like a linker error rather than a compiler error. If this is the case then you should check that the .CPP file is not added to the project twice. I also noticed that the extension is "php", this is very unusual as it should be "cpp".
Answer just for reference:
I was including
#include myclass.cpp
instead of
#include myclass.h
This can also happen if you have two .ui files with the same name in different folders. Their corresponding headers are built in the same directory, resulting in one being overwritten. At least that was my problem.
I got this error message when I had my slot declarations listed listed under the signals heading in the header file, rather than the slots one. Another thing for anyone experiencing this error message to check for.
Cut and paste solved the problem and a need to check next time I create Slots manually.
For me it was due to Qt's compilation model in Windows using MinGW.
My code compiled perfectly fine for Linux, but for Windows the linker errors were happening for following files:
Message.cpp
Util.cpp
At first, in the .pro file, I couldn't find any similar file names. Then observing keenly I figured out that, the external google protobuf library, which I was compiling along, had some library files inside its folder named as:
message.cc
util.cc
The cases and the extensions were different, but somehow it created mess in the Qt compilation. I just added an underscore to those library files and the things worked fine.
In my case this was caused by having the function declared globally in a header file.