Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Adding A Class In QtCreator
In QtCreator I add a class with QPlainTextEdit as the base class and I get the following;
class MyTextEditor : public QPlainTextEdit
#endif // MYTEXTEDITOR_H
However, I need the something like the following:
class MyPlainTextEditor : public QPlainTextEdit
MyPlainTextEditor(QWidget *parent = 0);
#endif // MYPLAINTEXTEDITOR_H
MyPlainTextEditor::MyPlainTextEditor(QWidget *parent) : QPlainTextEdit(parent)
My objective to promote the PlainTextEdit widget to MyPlainTextEditor. In the past I have added a MyCanvas class with QWidget as the base class to promote a QWidget and have never had to modify the code generated by QtCreator. If the base class is something other than QWidget, will I need to modify the code?
In the past I have added a MyCanvas class with QWidget as the base class to promote a QWidget and have never had to modify the code generated by QtCreator. If the base class is something other than QWidget, will I need to modify the code?
Yes, I also already noticed that the wizard is not clever enough to add the needed includes. (Btw:
#include <QPlainTextEdit>should be enought.) So you will have to edit this template a bit to get a compilable source file.
If you are annoyed about that, please file a bug at bugreports.qt.io
Yes it only support the shown includes.
In case of custom base class , no includes are added.
So, if the base class is custom, i.e., not listed in the drop-down list, then it is up to the programmer to finish the prototype and the constructor.
well its faster to use QWidget and just change to the wanted type.
If you use custom base class, it seems it does not call base class in ctor init list.
test::test(QWidget *parent) : QWidget(parent) <<< missing with custom
If you wish, they are easy to change
@mrjj Thanks. I will look into that.