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.)



  • @ofmrew

    Seems , you have forgotten
    # include"forumualrEdit.h" in cpp



  • make sure the pro file contains something like HEADERS += formulaeditor.h and re-run qmake


  • Qt Champions 2016

    @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.



  • @Ni.Sumi

    It is there I just did not show it.



  • @dheerendra

    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



  • @ofmrew

    Okay. Did you do this as @VRonin @mrjj and @dheerendra said ?

    Clean , and then Run qmake and then build ?


  • Qt Champions 2016

    @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.



  • @ofmrew

    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

    0_1493740126684_Capture.PNG



  • @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?


  • Qt Champions 2016

    @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.



  • @mrjj

    Thanks. I will remember this as I wasted hours chasing a phantom error.


  • Qt Champions 2016

    @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 up

    Then delete the build folder to be sure its an actual error and not just due to it using a
    cached version.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.