Hello,
I want to create a new QPushButton, so I inherited it like this:
Qt Code:
  1. class MyButton : public QPushButton
  2. {
  3. Q_OBJECT
  4. public:
  5. MyButton(const QString &text, QWidget *parent = 0);
  6.  
  7. };
To copy to clipboard, switch view to plain text mode 

the code of the constructor looks like this:
Qt Code:
  1. MyButton::MyButton(const QString &text, QWidget *parent)
  2. {
  3. btn = new QPushButton(text);
  4. btn->setFlat(true);
  5. //btn->show();
  6. btn->setMaximumHeight(30);
  7. }
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:
Qt Code:
  1. Btn1 = new MyButton("Hello World");
  2. layout->addWidget(Btn1);
To copy to clipboard, switch view to plain text mode