PDA

View Full Version : QProgressDialog



samirg
30th August 2007, 06:22
Dear Folks,

I could make QProgessBar dockable into QMainApplication, however, I could not succeed
in making QProgessDialog dockable into main application. I wonder if QProgresDialog
can be made dockable, if so, an example would or pointer to it, will be very helpfull.

regards,:confused:

aMan
30th August 2007, 07:32
I'm not sure, if i have understood you correctly. Are you using a QMainWindow and you want to add a QProgressBar dockable in it?

In designer just make a new QDockWidget, insert a progress bar and set the property "dockable" to true in the property window. Afaik QDockWidget only works in QMainWindow properly.

jpn
30th August 2007, 07:33
QDialog is a special widget:


Note that QDialog (an any other widget that has type Qt::Dialog) uses the parent widget slightly differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself). It will also share the parent's taskbar entry.


So you would have to switch its window type (http://doc.trolltech.com/latest/qwidget.html#windowFlags-prop) to something else than Qt::Dialog (http://doc.trolltech.com/latest/qt.html#WindowType-enum), then you can embed it into a QDockWidget. However, wouldn't QProgressBar be sufficient for you?

samirg
31st August 2007, 05:45
Thanks for all tips.

I want to be able to cancel the QProgressBar any time I want to, however, QProgressBar
does not seem to support 'cancel' operation. So, I came accross QProgressDialog which
supports "Cancel" operation. However, I could not make QProgressDialog dockable
into QMainWindow even if I change window type of QProgressDialog to something else.

I will try again.

regards,

jpn
31st August 2007, 08:06
Here's a small example:


// main.cpp
#include <QtGui>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QMainWindow window;

QLabel* label = new QLabel("Progressing...", &window);
window.setCentralWidget(label);

QDockWidget* dock = new QDockWidget(&window);
QProgressDialog* progress = new QProgressDialog(dock);
progress->setWindowFlags(Qt::Widget); // required to make the dialog a child widget
progress->setRange(0, 0); // to make progress go around forever
dock->setWidget(progress);
window.addDockWidget(Qt::BottomDockWidgetArea, dock);

QObject::connect(progress, SIGNAL(canceled()), label, SLOT(clear()));

window.show();
return app.exec();
}

samirg
5th September 2007, 16:37
Thank you, it was very helpfull, after ProgressDialog is made dockable into main window,
focus issue, I raised in another thread, is also, resolved.:)