how we can access data of one project within other project?
Page |
1 |
I want to use class of one project in other project.
23 replies
In .pro:
HEADERS = /path/to/old/headers/oldHeader.h SOURCES = /path/to/old/sources/oldSource.cppIn your new cpp header (or source):
@
#include “/path/to/old/headers/oldHeader.h”
@
I have tried this. Now i am able to access the other file object but while running the code i am getting error.
“No rule to make target ‘/Documents’, needed by ‘debug/documents.o’ stop. “
Does i have to include any more file or any other thing?
This is my both project which i am testing
- file_testing
- main.cpp
- #include <QtGui/QApplication>
- #include "mainwindow.h"
- #include "Documents and Settings/Pratik Agrawal/Desktop..........test1/mainwindow1.h"
- int main(int argc, char *argv[])
- {
- MainWindow w;
- MainWindow1 w1;
- w1.show();
- w.show();
- return a.exec();
- }
- mainwindow.cpp
- #include "mainwindow.h"
- {
- }
- mainwindow.h
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QtGui/QMainWindow>
- {
- Q_OBJECT
- public:
- ~MainWindow();
- };
- #endif // MAINWINDOW_H
- MainWindow::~MainWindow()
- {
- }
- file_testing.pro
- #-------------------------------------------------
- #
- # Project created by QtCreator 2011-12-08T15:07:18
- #
- #-------------------------------------------------
- QT += core gui
- TARGET = file_testing
- TEMPLATE = app
- SOURCES += main.cpp\
- mainwindow.cpp
- HEADERS += mainwindow.h
- HEADERS = Documents and Settings/Pratik Agrawal/............../test1/mainwindow1.h
- OTHER_FILES += \
- data.txt \
- N.txt
- RESOURCES += \
- resource.qrc
The project which i want to access
test1
- main.cpp
- #include <QtGui/QApplication>
- #include "mainwindow1.h"
- int main(int argc, char *argv[])
- {
- MainWindow1 w;
- w.show();
- return a.exec();
- }
- mainwindow1.cpp
- #include "mainwindow1.h"
- {
- }
- MainWindow1::~MainWindow1()
- {
- }
- mainwindow1.h
- #ifndef MAINWINDOW1_H
- #define MAINWINDOW1_H
- #include <QtGui/QMainWindow>
- {
- Q_OBJECT
- public:
- ~MainWindow1();
- };
- #endif // MAINWINDOW1_H
- test1.pro
- #-------------------------------------------------
- #
- # Project created by QtCreator 2011-12-12T09:55:33
- #
- #-------------------------------------------------
- QT += core gui
- TARGET = test1
- TEMPLATE = app
- SOURCES += main.cpp\
- mainwindow1.cpp
- HEADERS += mainwindow1.h
You’ve got spaces in your paths (file_testing.pro). That is why qmake understands “Documents” as a file. I don’t remember what a remedy for that was in qmake. Try either to enclose the whole path in quotes, or insert ‘\’ in front of every space (probably won’t work, as ‘\’ is used in a different manner in qmake).
Apart from that, I am not sure you can use 2 QMainWindows in a single app (I’ve never tried to, though. And I can’t find anything against it in QMW documentation, so maybe it’s OK).
You’ve got spaces in your paths (file_testing.pro). That is why qmake understands “Documents” as a file. I don’t remember what a remedy for that was in qmake. Try either to enclose the whole path in quotes, or insert ‘\’ in front of every space (probably won’t work, as ‘\’ is used in a different manner in qmake).Apart from that, I am not sure you can use 2 QMainWindows in a single app (I’ve never tried to, though. And I can’t find anything against it in QMW documentation, so maybe it’s OK).
I have used two QMainWindow before also. Their is no problem in using that. As you have suggested
i have checked using double quotes but in that case also it is showing error that
- No rule to make target 'path/mainwindow1.cpp' needed by 'debug/mainwindow1.o' . Stop.
I have checked removing spaces between the path also but i am getting the same error.
OK noticed another issue. In your code, you have this (shortened a bit for convenience):
- SOURCES += main.cpp\
- mainwindow.cpp
- HEADERS += mainwindow.h
- HEADERS = test1/mainwindow1.h
- SOURCES = test1/mainwindow1.cpp
The second invoke of HEADERS and SOURCES is followed by ‘=’, which means it will overwrite previous entries. Try this instead (remember to use your own paths):
- SOURCES += main.cpp \
- mainwindow.cpp \
- test1/mainwindow1.cpp
- HEADERS += mainwindow.h \
- test1/mainwindow1.h
OK noticed another issue. In your code, you have this (shortened a bit for convenience):
SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h HEADERS = test1/mainwindow1.h SOURCES = test1/mainwindow1.cppThe second invoke of HEADERS and SOURCES is followed by ‘=’, which means it will overwrite previous entries. Try this instead (remember to use your own paths):
@
SOURCES += main.cpp \ mainwindow.cpp \ test1/mainwindow1.cppHEADERS += mainwindow.h \ test1/mainwindow1.h
@
On changing this i am getting undeclared error.
You must log in to post a reply. Not a member yet? Register here!





