QtCore/QTextCodec not found in Qt 6 - c++

After upgrading to Qt 6.0, the compiler told me
qzxing/src/QZXing.cpp:16: error: 'QtCore/QTextCodec' file not found
qzxing/src/QZXing.cpp:16:10: fatal error: 'QtCore/QTextCodec' file not found
#include <QtCore/QTextCodec>
^~~~~~~~~~~~~~~~~~~
qzxing/src/QZXing.cpp:16:10: note: did not find header 'QTextCodec' in framework 'QtCore' (loaded from '/Applications/Qt/6.0.0/clang_64/lib')
According to Qt's documentation, it can be imported by adding QT += core5compat.
However, the compiler told me that "Unknown module(s) in QT: core5compat".
How to solve this problem?

Make sure that you have installed "Qt 5 Compatibility Module".
Add QT += core5compat in .pro file.
Replace #include <QtCore/QTextCodec> to #include <QTextCodec>

The QTextCodec class was moved to the core5compat submodule so it is not enough to add that in the .pro, but you must correct the import to:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtCore/QTextCodec>
#else
#include <QtCore5Compat/QTextCodec>
#endif
Or simply
#include <QTextCodec>
On the other hand, you must install this module since it does not come by default and for this you must use Maintenance Tool.

add greaterThan(QT_MAJOR_VERSION,5): QT += core5compat in .pro file

Related

How to include QwebEngineView without getting an error

Question is simple; I get an error "Unknown module QWebEngineView" when I write the line Qt += QWebEngineView in .pro file.
How to get rid of this ?
I have tried many solutions but still got the error when compiling. If you got a solution please explain it entirely step by step.
I run Qt 5.10.1 with Ming32 5.30.
Try to use msys2 project that contains mingw64 with patches for qt5.
Write in your .pro file
QT += webenginewidgets
Add
#include <QWebEngineView>
in file that will use QWebEngineView class

Error : 'bool QTabWidget::hasHeightForWidth() const' marked 'override', but does not override bool hasHeightForWidth() const Q_DECL_OVERRIDE;

I'm trying to build my qt application in REDHAT 6.5 but getting this error.
ERR CODE :
error: bool QTabWidget::hasHeightForWidth() const marked
'override', but does not override bool hasHeightForWidth() const
Q_DECL_OVERRIDE;
I'm using Qt 5
g++ version 6.3
In my .pro file i've already mentioned to use c++11 version that is
QMAKE_CXXFLAGS += -std=c++11
i've also tried setting
CONFIG += cpp11
but still it is throwing the same error. what else i'm missing?
I had this exact same error. It turned out to be due to a rogue Qt4-style include (in my case, QtGui/QTabWidget). Make sure you don't have any includes that are inadvertently pointing at Qt4 headers...
When I included these files, it worked ok.
#include <QtCore>
#include <QtGui>
#include <QDialog> //if you are using dialog boxes in this header or cpp file.

How to get phonon4qt5 to work with QT5?

I'm trying to get phonon4qt5 to work with QT5 but I'm getting:
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::AudioOutput ( no objectName ).
I've installed all the phonon related packages with apt.
I've added phonon4qt5 to my QT += in the .pro and LIBS += -L/home/fred/phonon-4.8.3/build5/phonon -lphonon4qt5 (tried several paths I found on my system)
And I've included these in my header:
#include <phonon4qt5/phonon/AudioDataOutput>
#include <phonon4qt5/phonon/AudioOutput>
#include <phonon4qt5/phonon/MediaObject>
#include <phonon4qt5/phonon/SeekSlider>
#include <phonon4qt5/phonon/VolumeSlider>
#include <phonon4qt5/phonon/AudioOutput>
Can someone point me to the correct direction?
(please don't suggest to use QMultimedia, since that's what I'm trying to get away from since there is no way to get the intensity of the sound output being played (in order to build a VU Meter..))
On the .cpp side I'm just doing:
Phonon::MediaObject *music =
Phonon::createPlayer(Phonon::MusicCategory,
Phonon::MediaSource("/home/fred/cpp/config/rol1.ogg"));
music->play();
Thank you for all your time and attention :-)
Best regards.
Fred.

Portaudio example "record_file.c" does not find "min"

First off, I alread got the smaller example paex_record.c to work.
I use MinGW on Windows8 and did compile portaudio from source, that's were I got the used libportaudio-2.dll from.
I set up a project in QtCreator (without gui) with following .pro-file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
LIBS += -LC:/Audio/patest/paex_record_file -llibportaudio-2
My folder C:/Audio/patest/paex_record_file looks like:
libportaudio-2.dll
main.cpp
pa_ringbuffer.c
pa_ringbuffer.h
pa_util.h
paex_record_file.pro
paex_record_file.pro.user
portaudio.h
I copied both pa_ringbuffer and pa_util to this folder after they were not found.
Main.cppcontains the whole example file paex_record_file.c from the portaudio source.
There is an error when calling the ringbuffer (line 246 and 271: source):
"min" was not declared in this scope
I thought this example would directly run just like the record.c example.
Do I need to include further packages? I've tried algorithm, math, std and using namespace std, but still the error occurs. But I get the feeling it should work out off box, perhaps my include files or folder setup / linkage is not ok?
EDIT: Ok so I just defined a min-function on my own. Now it throws different error:
undefined reference to "PaUtil_GetRingBufferReadAvailable"
and a couple more of this kind. There is probably a lib missing to be linked, having a look...
I also had this linking error trying to compile paex_record_file.c. Turns out you need to compile pa_ringbuffer.c before compiling the main file. There's also an external dependency on some alloc function, so you need to change 2 lines in the file.
I'm not savvy of qt but you need to do something like:
SOURCES += pa_ringbuffer.c main.cpp
Here's how I compile with MinGW:
Changes inside paex_record_file.c
Line 313 : data.ringBufferData = (SAMPLE *) malloc( numBytes );
Line 443 : free( data.ringBufferData );
Compile with MinGW:
gcc -o p_rec.exe C:\path_to_portaudio\portaudio\common\pa_ringbuffer.c \
paex_record_file.c -lportaudio \
-IC:\path_to_portaudio\portaudio\src\common
I didn't get the min problem, but perhaps you can try to remove the ifdef guard and try to recompile.
#ifdef _WIN32
#include <windows.h>
#include <process.h>
#endif
to
#include <windows.h>
#include <process.h>

#import <string> in ios? Protobuf c++ in ios

I am trying to get protobuf into xcode 4 and work with ios 5. I've done other tutorials none have worked. I have used a script to compile the libraries into arm 7 architecture and then added them to my project. This is the only thing that has worked so far.
My issue now is that I am trying to use the c++ generated files; however, I am getting an error saying #include -> lexical or preprocessor issue.
Any tips? It only showed this when I tried to run my project on the ipad. Before, it was fine with it.
Thanks. :)
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: addressbook.proto
#ifndef PROTOBUF_addressbook_2eproto__INCLUDED
#define PROTOBUF_addressbook_2eproto__INCLUDED
#include <string>
#include <google/protobuf/stubs/common.h>
//#include "google/protobuf/stubs/common.h"
#if GOOGLE_PROTOBUF_VERSION < 2004000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 2004001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
Update: This only breaks when I include it in an obj c file. I can make a Demo.h and include addressbook. Why can't I include addressbook.pb.h into an obj c file? Am I missing a setting somewhere? Which one?