try reading this,
setCancelButton
try reading this,
setCancelButton
Hmm... this is exactly what I used! setCancelButton(0) hides (it actually deletes) the button but the problem comes after that, when I create a new Cancel button. It appears at (0,0) in the dialog window, and I don't know how to move it there, where the previous one was. The code is functional, but it looks ugly![]()
I would suggest to put the logic inside the slot QProgressDialog::cancel () such that the functionality of Cancel is ignored. Even if you press 'Cancel' button nothing will happen. Not intuitive though!![]()
In that case it might be better to hold a QPointer<PushButton> instead of ignoring the action.
After looking into the qt source I think that the relayouting is missing. (in the qt source). You could check this if you trigger a resizeEvent for the Dialog.
Thanks guys!
I found a solution and here it is:
QList<QPushButton *> L=progressDialog.findChildren<QPushButton *>();
L.at(0)->hide();
L.at(0)->show();
Best regards!
I'd suggest disabling the button rather than hiding it. Users are normally happiest when the UI changes as little as possible, and keeping the button displayed but grayed out doesn't force a re-layout to occur.
Sure! You're right!![]()
Furthermore if you use setCancelButton() to set a new button, you don't need qFindChild to find it later. Just do it once before you enter the loop.
If QProgressDialog and the 'Cancel' button shares the parent-child relationship you can use findChild to get the QObject and do QObject casting to get the pushbutton*. Then you can use QWidget::geometry() to get the co-ordinates. Save it and use the same for your logic.
Bookmarks