HI,
I am trying to call Progress bar Dialog using thread from my main gui window but the progress bar does not proceed. Here is the code snippet.
From main
************
myGUI
::myGUI(QWidget *parent, Qt
::WFlags flags
) m_UiIsReadyToQuit(false)
{
ui.setupUi(this);
mProgressBarDialog = NULL;
connect(&thread, SIGNAL(ShowPB()),myPBarDialog,SLOT(PBoutput()));
}
void myGUI::Add_clicked()
{
if(myProBarDialog == NULL) {
myProBarDialog = new proBarDialog(this);
}
myProBarDialog->show();
// call the thread here
thread.render();
updateInstanceList();
// Stop the thread here
if (mProgressBarDialog != NULL)
{
mProgressBarDialog->close();
mProgressBarDialog = NULL;
}
thread.stop();
}
myGUI::myGUI(QWidget *parent, Qt::WFlags flags)
:QMainWindow(parent, flags),
m_UiIsReadyToQuit(false)
{
ui.setupUi(this);
mProgressBarDialog = NULL;
connect(&thread, SIGNAL(ShowPB()),myPBarDialog,SLOT(PBoutput()));
}
void myGUI::Add_clicked()
{
if(myProBarDialog == NULL) {
myProBarDialog = new proBarDialog(this);
}
myProBarDialog->show();
// call the thread here
thread.render();
updateInstanceList();
// Stop the thread here
if (mProgressBarDialog != NULL)
{
mProgressBarDialog->close();
mProgressBarDialog = NULL;
}
thread.stop();
}
To copy to clipboard, switch view to plain text mode
Thread code is like this
*****************
void PBarThread::render()
{
start(HighestPriority);
}
void PBarThread::run()
{
emit ShowPB();
}
and PBarDialog code is like this
******************
pBarDialog
::pBarDialog(QWidget *parent
){
ui.setupUi(this);
ui.pBar->show();
}
void pBarDialog::PBoutput()
{
ui.pBar->show();
}
void PBarThread::render()
{
start(HighestPriority);
}
void PBarThread::run()
{
emit ShowPB();
}
and PBarDialog code is like this
******************
pBarDialog::pBarDialog(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
ui.pBar->show();
}
void pBarDialog::PBoutput()
{
ui.pBar->show();
}
To copy to clipboard, switch view to plain text mode
In Debug mode I can see that the call goes to ui.pBar->show() (not in PBOutput function). I see a frozen progress dialog, although it is running in separate thread. Why do I see a frozen Progress dialog? Why the slot PBoutput is not called although debug shows that thread has emited ShowPB() signal.
Help,
Dove17
Bookmarks