how we can access data of one project within other project?
-
OK noticed another issue. In your code, you have this (shortened a bit for convenience):
@
SOURCES += main.cpp
mainwindow.cppHEADERS += 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.cppHEADERS += mainwindow.h
test1/mainwindow1.h
@ -
[quote author="sierdzio" date="1323681848"]OK noticed another issue. In your code, you have this (shortened a bit for convenience):
@
SOURCES += main.cpp
mainwindow.cppHEADERS += 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.cppHEADERS += mainwindow.h
test1/mainwindow1.h
@[/quote]
On changing this i am getting undeclared error. -
Do you use shadow builds with Qt Creator?
-
The code you gave is working for me, except that i changed
the header in the first project 'file_testing' to
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QtGui/QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(QWidget *parent = 0);
~MainWindow(){};
};#endif // MAINWINDOW_H@
I felt, the destructor was improperly positioned ;)
-
[quote author="Volker" date="1323688757"]Do you use shadow builds with Qt Creator?[/quote]
yes i used shadow build.
-
[quote author="pratik041" date="1323690516"]
[quote author="Volker" date="1323688757"]Do you use shadow builds with Qt Creator?[/quote]yes i used shadow build.[/quote]
Then I'm not 100% sure whether the approach I suggested does actually work as the directory layout is a bit delicate in that case.
-
[quote author="Rahul Das" date="1323690185"]The code you gave is working for me, except that i changed
the header in the first project 'file_testing' to
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QtGui/QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(QWidget *parent = 0);
~MainWindow(){};
};#endif // MAINWINDOW_H@
I felt, the destructor was improperly positioned ;)[/quote]
Actually in my code i have used it properly while pasting the destructor is pasted wrongly.
Does you are able to access other project object in your code? -
yes. i compiled and its working. I used the relative path. May be you should also try.
-
[quote author="Rahul Das" date="1323690185"]The code you gave is working for me, except that i changed
the header in the first project 'file_testing' to
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QtGui/QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(QWidget *parent = 0);
~MainWindow(){};
};#endif // MAINWINDOW_H@
I felt, the destructor was improperly positioned ;)[/quote]
I have tried using relative path but i dont know why the error is coming can you post your code? -
The project to be imported is in a folder named 'a spaced folder'.
main.cpp
@#include <QtGui/QApplication>
#include "mainwindow.h"
#include "../a spaced folder/test2/mainwindow1.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
MainWindow1 w1;
w.show();
w1.show();
w1.setWindowTitle("this is imported");
return a.exec();
}@Header
@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QtGui/QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(QWidget *parent = 0);
~MainWindow(){}
};#endif // MAINWINDOW_H
@source
@#include "mainwindow.h"MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
}
@
@QT += core guiTARGET = test
TEMPLATE = appSOURCES += main.cpp
mainwindow.cpp "../a spaced folder/test2/mainwindow1.cpp"HEADERS += mainwindow.h "../a spaced folder/test2/mainwindow1.h"@
Project to be imported.
pro
@
QT += core guiTARGET = test2
TEMPLATE = appSOURCES += main.cpp
mainwindow1.cppHEADERS += mainwindow1.h@
header
@#ifndef MAINWINDOW1_H
#define MAINWINDOW1_H#include <QtGui/QMainWindow>
class MainWindow1 : public QMainWindow
{
Q_OBJECTpublic:
MainWindow1(QWidget *parent = 0);
~MainWindow1();
};#endif // MAINWINDOW1_H@
Source
@#include "mainwindow1.h"MainWindow1::MainWindow1(QWidget *parent)
: QMainWindow(parent)
{
}MainWindow1::~MainWindow1()
{
}
@main.cpp
@#include <QtGui/QApplication>
#include "mainwindow1.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow1 w;
w.show();return a.exec();
}@