Solved Subclassing QTextEdit
-
I am trying to subclass QTextEdit to edit input so I can create symbolic math formula, but cannot get past the vtable issue.
formulaeditor.h
#include <QObject>
#include <QWidget>
#include <QTextEdit>class FormulaEditor : public QTextEdit
{
Q_OBJECT
public:
explicit FormulaEditor(QWidget *parent = 0);
// ~FormulaEditor();
};formulaeditor.cpp
FormulaEditor::FormulaEditor(QWidget *parent) : QTextEdit(parent)
{}
/*
FormulaEditor::~FormulaEditor(){}
*/
The commented out code was an attempt to get past the vtable problem. I have seen posts were other have done what I am attempting and my code is no defferent. Any suggestions? (I have promoted a Qt Creator QTextEdit to FormulaEditor.) -
Seems , you have forgotten
# include"forumualrEdit.h"
in cpp -
make sure the pro file contains something like
HEADERS += formulaeditor.h
and re-run qmake -
@ofmrew said in Subclassing QTextEdit:
vtable
You are not showing the actual error.
Try to Clean all, run qmake and the rebuild all.
-
Thrash the build directory and rebuild it. It will solve the issue.
-
It is there I just did not show it.
-
I did not understand "trash the build directory" but I did some of the items under the Build menu and now it works. Apparently I did trash the build directory, but now I want to know how I did it? Where is the build directory? And how do I trash it?
Thanks
-
Okay. Did you do this as @VRonin @mrjj and @dheerendra said ?
Clean , and then Run qmake and then build ?
-
@ofmrew
The build folder means the folder where it generates all the .o files and other stuff.
it will be in the same folder LEVEL as the project.
So goto the project folder, then one up and u should see build-xxxx-yyyy
And trash just means delete it. -
In Qt , whenever you add some new file (change in the somename.pro file) to your application, you need to run the qmake. Otherwise it will use the old files on your machine. When you run qmake, it will include the new files. qmake generates the platform dependent make files.
http://doc.qt.io/qt-5/qmake-manual.html
Built directory depends on you, where you allowed to build. Usually , you can find the path of the folder here
-
@mrjj and Ni.Sumi
I did Clean , and then Run qmake and then build as you suggested.
I normally just use Run (Green Triangle), which has always done the compile and execute with no problem; however, that now seems to be inadequate. If I always do a build, then will problems like this not occur?
-
@ofmrew
Well in normal development the RUN is enough.
But if u add to the pro file and rerun qmake, and it still makes errors then
removing the build folder will force it to recreate all.
It caches some stuff so sometimes its the best solution. -
Thanks. I will remember this as I wasted hours chasing a phantom error.
-
@ofmrew
Yep most of us have been there done that :)
So to make the "rules" clear.
if you add files to .PRO
if you add the Q_OBJECT macro
If you rename slots and its keeps acting upThen delete the build folder to be sure its an actual error and not just due to it using a
cached version.