QT_STATIC_CONST does not name a type - qt

I was using QT5.4.1 version with the QWT-6.1.2 library that I've installed but in compiling I receive the error "QT_STATIC_CONST does not name a type". After some researsh how to fix that, I found that I should install the QT version 5.5.
I have that already achieved but the error appears although!
I use Kubuntu by the way
What should I do ?

QT_STATIC_CONST’ does not name a type.
By defining QT_STATIC_CONST just before inserting Qwt file, compilation works.
- In Qt5.4 , QT_STATIC_CONST was removed from qglobal.h
- Qwt 6.1.1 uses this macro, but fixed it in Qwt 6.1.2

Here is the content that was removed from qglobal.h that created this issue. Adding this to your code prior to including the header file should resolve the issue.
/*
Workaround for static const members on MSVC++.
*/
#if defined(Q_CC_MSVC)
# define QT_STATIC_CONST static
# define QT_STATIC_CONST_IMPL
#else
# define QT_STATIC_CONST static const
# define QT_STATIC_CONST_IMPL const
#endif

Related

Crash on QwtPlotZoomer in QT5

I am trying to use a QwtPlotZoomer in QT5, but I get a seg fault when its constructor runs.
class Qwt_widget : public QwtPlot
{
Q_OBJECT
public:
Qwt_widget(QWidget* parent = 0) :
QwtPlot(parent),
m_canvas()
{
QwtPlotZoomer zoomer(&m_canvas); // Crashes here
}
private:
QwtPlotCanvas m_canvas;
};
The above widget is added to a simple main window so that it will be created (full code at https://github.com/chrisburnham/Qwt_qt5_crash). Also here are the QWT lines that I have added to the QT creators default pro file:
INCLUDEPATH += /usr/include/qwt
LIBS += -lqwt-qt5
I am running on Ubuntu 18.04 and installed Qt5 with libqt5-default (5.9.5) and QWT with libqwt-qt5-dev (6.1.3). I have checked all my libraries with LDD and looked at the headers I am using and they are all coming from the packages that were installed with libqwt-qt5-dev. I have previously used QwtPlotZoomers in this way in Qt4 (with the Qt4 version of QWT) and as far as I can tell from the documentation it should still work here.
You need to assign the QwtPlotCanvas to the QwtPlot before you ask QwtPlotZoomer to work on it. Note that QwtPlot::setCanvas() takes ownership, so do not use a member variable for the canvas.
But since you are using a default QwtPlotCanvas and not some derived class you could probably just use the canvas QwtPlot comes with:
QwtPlotZoomer zoomer(this->canvas()); // Should not crash here

QtCreator: kit-specific precompiler macro definitions

I am using QtCreator 3.1.1 to build a cross-platform project, and so I arranged to have different compilation kits for targeting my desktop PC and my BeagleBoneBlack (BBB).
Now I would like to define some macro in qmake project file (.pro) which are specific only for a given kit.
In other words I would like do in my .pro file something like:
if(kit == BBB)
DEFINES += MY_BBB_MACRO
elseif(kit == Desktop)
DEFINES += MY_DESKTOP_MACRO
else
DEFINES += OTHER_MACRO
Is is possible? How can I do that?
I obtained some help on Qt forum (take a look here) about this problem...
Anyway the solution consists in using qmake built-in test functions.
Basically I've added some CONFIG directive in QtCreator's project management: in the following screenshot you can see for example you can see that I've added CONFIG+=BBB in the project configuration for BBB kit; in the same way I've added CONFIG+=AM335x and CONFIG+=Desktop to AM335x and Desktop kits, respectively...
Then, in my .pro file I've added something like:
and now in my source code I can use something like #ifdef PLATFORM_BBB, #ifdef PLATFORM_AM335X and #ifdef PLATFORM_DESKTOP for differentiating the program behavior depending on compilation kit.
I found another solution.
First, add additional arguments in Projects using CONFIG+=Variable name for kit.
And in .pro file, write some code like below.
Desktop {
message("Desktop is selected")
}
RPI {
message("rpi is selected")
target.path = /home/pi
INSTALLS += target
}
If you look at the general message tab, you can see that the setting works well.

Compiling QtOpenCL with QT5

Anyone managed to compile library QtOpenCL using Qt5 (possibly under Window)?
edit: I managed to compile the code by porting it to QT5. I leave here in the question the dirty parts that I would like to replace in my method and describe what I did in the answer.
I was not able to provide the include path to my opencl installation so I
manually modified src/opencl/opencl.pro by adding the line
INCLUDEPATH += " *[absolute path to the openCL include folder]* "
QMAKE_LIBDIR_OPENCL = "*[absolute path to the opencl lib folder]*"
manually modified src/openclgl/openclgl.pro by adding the line
INCPATH += " *[absolute path to the openCL include folder]* "
QMAKE_LIBDIR_OPENCL = "*[absolute path to the opencl lib folder]*"
Anyone knows how to fix this in a cleaner way?
Here are the changes I had to introduce:
Modify the .pro files in order to add the OpenCL library. This is still an open problem for me. How to fix this in a cleaner way?
Link the projects (both opencl.pro and openclgl.pro) to the additional required Qt module QtConcurrent:
QT += concurrent
Fix the #include style by removing the packages, e.g. #include <qtconcurrentrun.h> instead of the old #include
<QtCore/qtconcurrentrun.h>
Fix qclvector.cpp by replacing qMalloc, qfree, qMemCopy with, respectively, std::malloc, std::free, std::memcpy
Moreover modify the initialization of ref in the constructor from ref = 1 to ref.store(1);
Removing all the macros QT_LICENSED_MODULE
This is enough to compile at least QtOpenCL and QtOpenCLGL using QT5

Qt program does not link, no moc file generated

I'm using Qt, CMake, and the VS2010 compiler. There seems to be a problem when I'm linking a small piece of test code. The linkers gives the following error:
plotter.cpp.obj : error LNK2001: unresolved external symbol "public: virtual str
uct QMetaObject const * __thiscall Plotter::metaObject(void)const " (?metaObject
#Plotter##UBEPBUQMetaObject##XZ)...
(it goes on for a while)
The error occurs when I'm trying to inherit from QObject in the following code:
class Plotter : public QObject
{
Q_OBJECT
public:
If I leave out the Q_OBJECT, the program links, but I can't use the class slots at runtime.
I noticed that no moc file is generated for plotter.h. This is my CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (ms)
SET(CMAKE_BUILD_TYPE "Release")
FIND_PACKAGE(Qt4)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
LINK_LIBRARIES(
${QT_LIBRARIES}
)
set(all_SOURCES plotter.cpp main.cpp dialog.cpp)
QT4_AUTOMOC(${all_SOURCES})
add_executable(ms ${all_SOURCES})
target_link_libraries(ms ${LINK_LIBRARIES})
A moc file is generated for dialog.cpp, but not for plotter.cpp, how is this possible?
Thanks!
First of all, ensure you are using QT4_AUTOMOC correctly. As the documentation points out, you still need to properly include the mocced files in your sources.
Also notice that QT4_AUTOMOC is still marked as experimental by CMake, so be sure it actually does what you expect and correctly generates the required files. If not, consider switching to the more robust classic solution using QT4_WRAP_CPP:
# notice that you need to pass the *header* here, not the source file
QT4_WRAP_CPP(MY_MOCED_FILES plotter.hpp)
# optional: hide the moced files in their own source group
# this is only useful if using an ide that supports it
SOURCE_GROUP(moc FILES ${MY_MOCED_FILES})
# then include the moced files into the build
add_executable(ms ${all_SOURCES} ${MY_MOCED_FILES})
Apart from that, your CMake file seems fine.

Flex compile problem with as3httpclient

I am having trouble getting a Flex application (with as3httpclient) to work.
I compiled it (compc -load-config=build-swc.xml), put the as3httpclientlib-1_0_6.swc in my libs dir, and ran
mxmlc -compiler.include-libraries lib/as3crypto-1_3_patched.swc
lib/as3httpclientlib-1_0_6.swc lib/corelib.swc -- App.mxml
In my actionscript I
import org.httpclient.HttpClient;
but still I receive the error
Error: Type was not found or was not a compile-time constant: HttpStatusEvent
client.listener.onStatus = function(event:HttpStatusEvent):void {
...
. Any ideas?
btw / before compiling "compc -load-config=build-swc.xml" I hade to
change
<path-element>${flexlib}/libs/player/9/playerglobal.swc</path-element>
to
<path-element>${flexlib}/libs/player/10.0/playerglobal.swc</path-element>
in order for it to compile because my flex version doesn't have a playerglobal.swc for Flash 9. 8o
Unless this is a custom defined class, there is no such thing as HttpStatusEvent, you need to import flash.events.HTTPStatusEvent and refer to it as such.

Resources