Hello,
I want to create a new QPushButton, so I inherited it like this:
{
Q_OBJECT
public:
};
class MyButton : public QPushButton
{
Q_OBJECT
public:
MyButton(const QString &text, QWidget *parent = 0);
QPushButton *btn;
};
To copy to clipboard, switch view to plain text mode
the code of the constructor looks like this:
{
btn->setFlat(true);
//btn->show();
btn->setMaximumHeight(30);
}
MyButton::MyButton(const QString &text, QWidget *parent)
{
btn = new QPushButton(text);
btn->setFlat(true);
//btn->show();
btn->setMaximumHeight(30);
}
To copy to clipboard, switch view to plain text mode
When I now add a new MyButton to my MainWindow widget it does not show up, but when I remove the two slashes before btn->show(), the new button is drawn in a separate window. Why does the button only appear in a separate window and not in my main widget?
Here is the code snipped from the main widget:
Btn1 = new MyButton("Hello World");
layout->addWidget(Btn1);
Btn1 = new MyButton("Hello World");
layout->addWidget(Btn1);
To copy to clipboard, switch view to plain text mode
Bookmarks