
Originally Posted by
dsedov
Hi. I am writing a software using VS2008 and QT4.3.3 with VS integration and it's structure is following:
First project is an application
Second project is a Qt Library project which produces a DLL. Now the problem I am having is that when I include DLL header file into my application compiled can't find auto generated ui_***.h file.
How should I go about including several widgets that I plan to use into a single DLL and be able to use QT Designer. If I were to write a widget from scratch without using .ui files - everything works. But the problem is that DLL compiles just fine, but the actual application, when includes DLL header (which also includes auto generated ui_***.h files) does not find those auto generated headers.
Maybe there is some other way to write a single DLL projects which includes several widgets?
at the first you need to create h-file with the following content (e.g. myglobal.h)
#ifndef MYGLOBAL_H
#define MYGLOBAL_H
#include <QtGlobal>
#ifdef MY_LIB_STATICLIB
# undef MY_LIB_SHAREDLIB
# define MY_LIB_EXPORT
#else
# ifdef MY_LIB_MAKEDLL
# define MY_LIB_EXPORT Q_DECL_EXPORT
# else
# define MY_LIB_EXPORT Q_DECL_IMPORT
# endif
#endif
#endif//MYGLOBAL_H
#ifndef MYGLOBAL_H
#define MYGLOBAL_H
#include <QtGlobal>
#ifdef MY_LIB_STATICLIB
# undef MY_LIB_SHAREDLIB
# define MY_LIB_EXPORT
#else
# ifdef MY_LIB_MAKEDLL
# define MY_LIB_EXPORT Q_DECL_EXPORT
# else
# define MY_LIB_EXPORT Q_DECL_IMPORT
# endif
#endif
#endif//MYGLOBAL_H
To copy to clipboard, switch view to plain text mode
then in pro-file of your lib you should add next thing
...
contains(CONFIG, staticlib) {
DEFINES += MY_LIB_STATICLIB
} else {
DEFINES += MY_LIB_SHAREDLIB
}
win32 {
DEFINES += MY_LIB_MAKEDLL
}
...
...
contains(CONFIG, staticlib) {
DEFINES += MY_LIB_STATICLIB
} else {
DEFINES += MY_LIB_SHAREDLIB
}
win32 {
DEFINES += MY_LIB_MAKEDLL
}
...
To copy to clipboard, switch view to plain text mode
and then you must add MY_LIB_EXPORT before class name which you want to export
#include "myglobal.h"
class MY_LIB_EXPORT MyObj
{
...
};
#include "myglobal.h"
class MY_LIB_EXPORT MyObj
{
...
};
To copy to clipboard, switch view to plain text mode
Bookmarks