The thing you are calling show() on is the the QWidget-derived ProgressBar object: and it will be shown. That object has created a few other objects that it owns (a generic QDialog and QProgressBar) but as it never puts them in a layout in its client area or explicitly show()s them these objects have no visible manifestation. Ownership does not equal visibility.
What you want is more like this:
#include <QtGui>
class ProgressDialog
: public QDialog{
Q_OBJECT
public:
pb1->setValue(10);
pb2->setValue(50);
pb3->setValue(90);
connect(bb, SIGNAL(rejected()), SLOT(reject()));
connect(bb, SIGNAL(accepted()), SLOT(accept()));
layout->addWidget(label);
layout->addWidget(edit);
layout->addWidget(pb1);
layout->addWidget(pb2);
layout->addWidget(pb3);
layout->addWidget(bb);
}
};
int main(int argc, char **argv)
{
ProgressDialog pb;
pb.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
class ProgressDialog: public QDialog
{
Q_OBJECT
public:
explicit ProgressDialog(QWidget *p = 0): QDialog(p) {
QLabel *label = new QLabel("A Label", this);
QTextEdit *edit = new QTextEdit(this);
QProgressBar *pb1 = new QProgressBar(this);
pb1->setValue(10);
QProgressBar *pb2 = new QProgressBar(this);
pb2->setValue(50);
QProgressBar *pb3 = new QProgressBar(this);
pb3->setValue(90);
QDialogButtonBox *bb = new QDialogButtonBox(this);
bb->addButton(QDialogButtonBox::Cancel);
bb->addButton(QDialogButtonBox::Ok);
connect(bb, SIGNAL(rejected()), SLOT(reject()));
connect(bb, SIGNAL(accepted()), SLOT(accept()));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(label);
layout->addWidget(edit);
layout->addWidget(pb1);
layout->addWidget(pb2);
layout->addWidget(pb3);
layout->addWidget(bb);
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
ProgressDialog pb;
pb.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks