Loop images within one QDialog, closing all Windows and open new Window with button
-
I need to loop images within one QDialog, closing all Windows and open new Window with button
using chunk below:
#include "DialogManager.h" QList<QDialog*> DialogManager::dialogs; void DialogManager::addDialog(QDialog *dialog) { if (dialog) { dialogs.append(dialog); } } void DialogManager::closeAllDialogs() { for (QDialog *dialog : dialogs) { if (dialog) { dialog->close(); } } dialogs.clear(); } qDebug() << "Closing all dialogs"; qDebug() << "Attempting to close current dialog"; this->close(); QTimer::singleShot(0, this, [this]() { qDebug() << "Current dialog closed, creating new Frames dialog"; ClassName *a = new ClassName(); a->functionName(l_path, qnumber, "", ""); a->setWindowFlag(Qt::WindowStaysOnTopHint); a->setGeometry(0, 0, 1850, 850); // Adjust the geometry as needed a->setWindowTitle("Frame#" + qnumber); a->setAttribute(Qt::WA_DeleteOnClose); a->show(); }); DialogManager::closeAllDialogs();
but I can only use this function this way
I open QDialog, push button to open next image, it closes current dialog
returns to mainWindow where I repeat this cycle
its not really convenient, so I'm asking for your kind support -
I need to loop images within one QDialog, closing all Windows and open new Window with button
using chunk below:
#include "DialogManager.h" QList<QDialog*> DialogManager::dialogs; void DialogManager::addDialog(QDialog *dialog) { if (dialog) { dialogs.append(dialog); } } void DialogManager::closeAllDialogs() { for (QDialog *dialog : dialogs) { if (dialog) { dialog->close(); } } dialogs.clear(); } qDebug() << "Closing all dialogs"; qDebug() << "Attempting to close current dialog"; this->close(); QTimer::singleShot(0, this, [this]() { qDebug() << "Current dialog closed, creating new Frames dialog"; ClassName *a = new ClassName(); a->functionName(l_path, qnumber, "", ""); a->setWindowFlag(Qt::WindowStaysOnTopHint); a->setGeometry(0, 0, 1850, 850); // Adjust the geometry as needed a->setWindowTitle("Frame#" + qnumber); a->setAttribute(Qt::WA_DeleteOnClose); a->show(); }); DialogManager::closeAllDialogs();
but I can only use this function this way
I open QDialog, push button to open next image, it closes current dialog
returns to mainWindow where I repeat this cycle
its not really convenient, so I'm asking for your kind support@JacobNovitsky said in Loop images within one QDialog, closing all Windows and open new Window with button:
I need to loop images within one QDialog
The posted code doesn't show anything related to "loop images"?!
And I find it quite confusing what you do with your dialogs.Can you tell what you are actually looking for? What should the
Dialog
do?Where do your images come from? How do you store them? Do you want to show them one after another? Like a slide show?
-
@JacobNovitsky said in Loop images within one QDialog, closing all Windows and open new Window with button:
I need to loop images within one QDialog
The posted code doesn't show anything related to "loop images"?!
And I find it quite confusing what you do with your dialogs.Can you tell what you are actually looking for? What should the
Dialog
do?Where do your images come from? How do you store them? Do you want to show them one after another? Like a slide show?
@Pl45m4
images stored at ~/Pictures
I need to loop each image and see its output on button click on same Dialog
each button click must close previous Dialog and Open new (refresh, to prevent memory leak) -
Hi,
Why not change the content of the label rather than recreating the exact same dialog all the time ?
-
Hi,
Why not change the content of the label rather than recreating the exact same dialog all the time ?
@SGaist do you mean pushbutton -> set new label?
-
@SGaist do you mean pushbutton -> set new label?
@JacobNovitsky Just call QLabel::setPixmap(const QPixmap &) to the next pixmap.
-
@Pl45m4
images stored at ~/Pictures
I need to loop each image and see its output on button click on same Dialog
each button click must close previous Dialog and Open new (refresh, to prevent memory leak)@JacobNovitsky said in Loop images within one QDialog, closing all Windows and open new Window with button:
images stored at ~/Pictures
I need to loop each image and see its output on button click on same Dialog
each button click must close previous Dialog and Open new (refresh, to prevent memory leak)No.
How about reading all files name and store them in someQFileInfoList
and then navigate through the list showing one image at a time in the same dialog. You don't have to re-create the dialog to show another image. -
@JacobNovitsky said in Loop images within one QDialog, closing all Windows and open new Window with button:
images stored at ~/Pictures
I need to loop each image and see its output on button click on same Dialog
each button click must close previous Dialog and Open new (refresh, to prevent memory leak)No.
How about reading all files name and store them in someQFileInfoList
and then navigate through the list showing one image at a time in the same dialog. You don't have to re-create the dialog to show another image.@Pl45m4 thanks! I was pretty dumb to not consider this natural variant