Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
class Wizard : public QDialog
{
Q_OBJECT
public:
Wizard(QWidget *parent);
private slots:
void what_ever();
private:
QPushButton *what_ever;
};
Wizard::Wizard( QWidget *parent ) : QDialog(parent)
{
QGridLayout *layout = new QGridLayout( this );
QScopedPointer<QTextEdit> textEdit(new QTextEdit);
layout->addWidget( textEdit.take(), 0, 0, 1, 2 );
what_ever = new QPushButton("whatever");
layout->addWidget(what_ever, 0, 1, 1, 1);
connect(what_ever, SIGNAL(clicked()), this, SLOT(what_ever()));
}
void Wizard::what_ever()
{
//blah blah blah
}
I have some problems about the codes.
1 : What if textEdit throw exception?
If "textEdit" throw exception, that means the
destructor of Wizard would not be called,
What would Qt handle the resource of "layout"?
2 : Could I initialize "what_ever" like this?
layout->addWidget(what_ever = new QPushButton("whatever"), 0, 1, 1, 1);
Is this safe in Qt4(4.8)?Would it have any change to cause memory leak?
Thanks a lot