0
votes

I would like to promote two widgets: the QTextEdit and QTextBrowser to paint something in the background.

I successfully promoted the QTextEdit. But I can't get the QTextBrowser done. I tried to promote the QTextBrowser to Display Class.

This is the code:

class Display : public QTextBrowser
{
    Q_OBJECT
 public:
    Display(QWidget* parent = 0);
};


Display::Display(QWidget* parent):QTextBrowser(parent)
{
    qDebug() <<"Hello. I am Display";
}

In the designer. It seems to be promoted but it doesn't do anything.

Then I change something for testing. I promote the QTextBrowser to Foo with header foo.h which does not exist anywhere in my project. Surprisingly, it let me do so. I rebuild the project and open the ui_mainwindow.h. I can see these code:

#include "foo.h"
................
foo *textBrowerOutput;
................

textBrowerOutput = new foo(centralWidget);
textBrowerOutput->setObjectName(QStringLiteral("textBrowerOutput"));
textBrowerOutput->setFont(font6);

My program runs perfectly despite the QTextBrowser works as default. I don't understand why my promotion is not working. At the same time, I don't understand how foo can complie without error.

1

1 Answers

0
votes

I finally create a new project. Copy only .cpp , .h, the main .pro file and a .ui file to that new project. It works after rebuilding.