Unsolved How to remove icon from QMessageBox button
-
How to remove icon in button form QMessageBox, and how to change the place of yes no button as vise versa in messageBox.
msg = QMessageBox(QMessageBox.Icon.Question, 'Delete ', 'Are you sure you want to exit?', buttons=QMessageBox.No | QMessageBox.Yes)
-
@yashi95 said in How to remove icon from QMessageBox button:
How to remove icon in button form QMessageBox,
Try QMessageBox::NoIcon, if it works.
and how to change the place of yes no button as vise versa in messageBox
I don't think you can alter the order/layout of buttons. Write your own modal dialog if you really want this. EDIT Actually, you can't alter, but looks like you can start with no buttons and use
QMessageBox::addButton()
to add buttons with desired text and correct role, presumably it adds those left->right so try that. -
@JonB Itseems QmessageBox::NoIcon will remove the icon form QmessageBox i.e Question, Information etc.
But i want to remove icon in button which in message box -
@yashi95
Then presumably use the void QMessageBox::addButton(QAbstractButton *button, QMessageBox::ButtonRole role) overload to get exactly the button/look you want? -
import sys from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * class ErrorWindow(QMessageBox): def __init__(self, parent=None): QMessageBox.__init__(self, parent) self.setWindowTitle("Example") self.addButton(QPushButton("Yes"), QMessageBox.YesRole ) self.addButton(QPushButton("No"), QMessageBox.NoRole) self.addButton(QPushButton("Cancel"), QMessageBox.RejectRole) if __name__ == "__main__": app = QApplication(sys.argv) ex = ErrorWindow() ex.setText("some error") ex.show() sys.exit(app.exec_())
So, i am getting only "some error" on that dialog
-
Hi,
Which version of PySide2 are you using ?
On which platform ? -
@SGaist
Hi,
pyside2 version 5.14.2.1
Platform ubuntu
FYI - i am able to show QMessageBox without icon.
Thank you