Greetings, everyone.
Here is my problem: I use Qt-4.8.5 (I need that version for work, another versions aren't compatible with my goals). In process of learning QEvents i added some code (functions that override virtual event handling functions and includings of event headers) into some of my classes inherited from QWidget, but deleted that added code later. Since that time when i trying to make new class that inherits QWidget (even in absolutely new projects and in classes that already exist in old projects), compiler says something like that:
(.
rodata._ZTV10MainWindow
[vtable
for MainWindow
]+0xc8
):-1: error
: undefined reference to `
QWidget::event(QKeyEvent*)' :-1: error: collect2: ld returned 1 exit status
(.rodata._ZTV10MainWindow[vtable for MainWindow]+0xc8):-1: error: undefined reference to `QWidget::event(QKeyEvent*)'
:-1: error: collect2: ld returned 1 exit status
To copy to clipboard, switch view to plain text mode
even if there is no usage of any kind of events in project (I experimented with QKeyEvents too).
Here is an example of simpliest project that has been created during attempts to find out true source of problem (if additional information is necessary then I ready to provide it, but at the moment I can't even imagine what kind information is necessary in addition to that one):
PRO-file (generated by Qt Creator):
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled1
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled1
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
To copy to clipboard, switch view to plain text mode
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QHBoxLayout>
#include <QLabel>
{
Q_OBJECT
//protected:
// virtual void event(QKeyEvent *)
// {
// }
public:
explicit MainWindow
(QWidget *parent
= 0);
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QHBoxLayout>
#include <QLabel>
class MainWindow : public QWidget
{
Q_OBJECT
//protected:
// virtual void event(QKeyEvent *)
// {
// }
public:
explicit MainWindow(QWidget *parent = 0);
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
By the way, if function
virtual void event(QKeyEvent *)
To copy to clipboard, switch view to plain text mode
in mainwindow.h is uncommented then everithyng compiles normally and works fine.
mainwindow.cpp:
#include "mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) :{
}
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QWidget(parent)
{
}
To copy to clipboard, switch view to plain text mode
main.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Cleaning projects and rebuilding them haven't helped to solve this problem so as manual removing of folder with builded project (I use Qt-creator, but with only qmake and make commands problem still appears)
But standard Qt classes, inherited from QWidget (QDialog, QMainWindow etc) and QWidget itself work normally (I mean, if project has not custom classes inherited from QWidget then everything works fine). For finding true source of problem I tried to compile it with Qt-4.8.6, and this mistake did not appear (but I can't use 4.8.6 permanently)
It is curious, but there were no compile errors for another QWidget::event() functions and any functions of QWidget or other class.
Additional information:
Platform: Linux Red Hat Enterprise Edition 64-bit
Compiler version: gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4) 64-bit
Qt and QMake version: Qt-4.8.5
Qt Creator version: 2.7.2
The question is: what can cause this problem ( and what could I break, because everithyng used to work fine before ) and what should I try to get rid of it assuming that I have no ability to reinstall Qt and Qt-creator (it is not my own computer)?
Thanks in advance for any help.
Bookmarks