I have been playing around with the promote feature of designer. I discovered it on my own and realized it must be pertinent. However, it is no simple task to specialize a widget if you are new to this. The compiler whines incessantly when I promote the TextEdit widget to TextEditEx specifying header file AllTextEx.h.
When I do this:
"AllTextEx.h"
Q_OBJECT
protected:
signals:
void pressedReturn();
};
class QTextEditEx : public QTextEdit {
Q_OBJECT
protected:
bool eventFilter(QObject* obj, QEvent *event);
signals:
void pressedReturn();
};
To copy to clipboard, switch view to plain text mode
I get: ./AllTextEx.h:2: error: expected class-name before '{' token...
When I do this:
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTextBrowser>
#include <QtGui/QWidget>
Q_OBJECT
protected:
signals:
void pressedReturn();
};
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTextBrowser>
#include <QtGui/QWidget>
class QTextEditEx : public QTextEdit {
Q_OBJECT
protected:
bool eventFilter(QObject* obj, QEvent *event);
signals:
void pressedReturn();
};
To copy to clipboard, switch view to plain text mode
I get:
ui_MChat.h: In member function `void Ui_MChat::setupUi(QMainWindow*)':
ui_MChat.h:47: error: no matching function for call to `QTextEditEx::QTextEditEx(QWidget*&)'
And even something like this yields linker errors:
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTextBrowser>
#include <QtGui/QWidget>
Q_OBJECT
private:
public:
QTextEditEx
(QWidget* widget
) : mainWindow
(widget
) {}protected:
signals:
void pressedReturn();
};
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTextBrowser>
#include <QtGui/QWidget>
class QTextEditEx : public QTextEdit {
Q_OBJECT
private:
QWidget* mainWindow;
public:
QTextEditEx(QWidget* widget) : mainWindow(widget) {}
protected:
bool eventFilter(QObject* obj, QEvent *event);
signals:
void pressedReturn();
};
To copy to clipboard, switch view to plain text mode
I get:
MChat.cpp.text$_ZN8Ui_MChat7setupUiEP11QMainWindow[Ui_MChat::setupUi(QMainWindow*)]+0x343): undefined reference to `vtable for QTextEditEx'
MChat.cpp.text$_ZN8Ui_MChat7setupUiEP11QMainWindow[Ui_MChat::setupUi(QMainWindow*)]+0x353): undefined reference to `vtable for QTextEditEx'
Bookmarks