In your constructor, you aren't calling the base class constructor. If your QTMainForm has a parent, this means that the proper parent-child relationship is not being set up.
Since you don't give a header file, it is impossible to know what class QTMainForm is derived from, so I will assume it is QDialog for the purpose of the example:
QTMainForm
::QTMainForm(QWidget* parent
): QDialog( parent
) // <---- you should always do this, even if "parent" is NULL {
btn.setText("start");
btn2.setText("stop");
connect(&btn, SIGNAL(clicked()), this, SLOT(OnBtnstrt()));
progress.setValue(0);
progress.setRange(0, 1000000);
progress.setWindowTitle(tr("Find Files"));
vb.addWidget(&progress);
vb.addWidget(&btn);
vb.addWidget(&btn2);
setLayout(&vb);
}
QTMainForm::QTMainForm(QWidget* parent)
: QDialog( parent ) // <---- you should always do this, even if "parent" is NULL
{
btn.setText("start");
btn2.setText("stop");
connect(&btn, SIGNAL(clicked()), this, SLOT(OnBtnstrt()));
progress.setValue(0);
progress.setRange(0, 1000000);
progress.setWindowTitle(tr("Find Files"));
vb.addWidget(&progress);
vb.addWidget(&btn);
vb.addWidget(&btn2);
setLayout(&vb);
}
To copy to clipboard, switch view to plain text mode
Please learn about "CODE" tags and use them next time you post source code. (Click "Go Advanced" then click the "#" icon on the toolbar. This inserts a pair of CODE tags. Paste your source code in between them). This will also preserve any indentation in your source file, which will make your code easier to read.
Bookmarks