Questions tagged [qmessagebox]

QMessageBox is a Qt class that provides a modal window for informing the user or asking for a simple input (like "yes"/"no").

The simplest QMessageBox to alert a user will look like this:

QMessageBox myBox;
myBox.setText("Hello, World!");
myBox.exec();

This will pop up a small modal window (which will block the rest of the interface until dismissed) with the text, and a standard "ok" button.

Basically the QMessageBox provides text for informing the user, informative text for a more detailed explanation, and an optional detailed text for even more additional info, should the user request it. The message box can also have standard buttons.

The official documentation can be found here for Qt 4.8 and here for Qt 5.

233 questions
1
vote
0 answers

In QDialogButtonBox, where does it disconnect on-destroy connection of buttons when dialog closed?

I want to build something like QMessageBox but with my own style and layout. So I am tracing qt's source code and learn from it. QMessageBox is composed with some label widgets as content and QDialogButtonBox as buttons. int ret =…
Opass
  • 79
  • 1
  • 8
1
vote
1 answer

Connecting in PyQt4 QMessageBox fails to call the slot method

I was trying to analyse the sample code cited here: PyQt - QMessageBox Here's the snippet: from PyQt4.QtGui import * from PyQt4.QtCore import * class Window(QMainWindow): def __init__(self): super().__init__() w = QWidget() …
1
vote
1 answer

PyQt5: How to display list in QMessageBox? TypeError: argument 3 has unexpected type 'list'

I'm trying to display a list in a QMessageBox I keep getting error: TypeError: question(QWidget, str, str, buttons: Union[QMessageBox.StandardButtons, QMessageBox.StandardButton] = QMessageBox.StandardButtons(QMessageBox.Yes|QMessageBox.No), …
1
vote
0 answers

How to hide QMessageBox when the Standard Buttons are clicked?

What I want to achieve here is, when I click the close button(X) or the standard buttons(OK|Yes|No|...) on the QMessageBox, instead of closing the QMessageBox, I just want to hide it. I override the closeEvent(QCloseEvent *event) function, so when…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
1
vote
1 answer

How to subclass QMessageBox and run operation before closing

I would like to launch a process within a QMessageBox subclass before it returns via the AcceptRole. It's not clear to me why the following does not work: class Question(QtGui.QMessageBox): def __init__(self, text): …
tom voll
  • 55
  • 5
1
vote
1 answer

QMessageBox without Icon

Normally, when creating a QMessageBox, the window icon will look like this: But I want to have a QMessageBox without the window/title bar icon, like this: I did some research and saw that I have to use QMessageBox::NoIcon. I tried, but it did not…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
1
vote
0 answers

QMessageBox is not positioned correctly when shown during startup

I have a program that takes one command line parameter (the file to load). If something goes wrong while loading the file, a QMessageBox is shown. It's not placed correctly (not centered on the MainWindow), most probably because the show() process…
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
1
vote
1 answer

How to add custom button roles to custom buttons in QMessageBox

I want to create a python GUI using QMessageBox Widget with custom buttons and custom button roles. I have created custom buttons but how to add custom role to a button when it is clicked. The widget has standard button roles but I want to define…
pavan sunder
  • 99
  • 4
  • 15
1
vote
1 answer

Can not set Stylesheet for buttons in QMessageBox

I don't know where I am wrong with setStyleSheet, but the result is not as I want. Could you guys tell me where the problem is? if (!closedialog) { closedialog = new…
trangan
  • 341
  • 8
  • 22
1
vote
0 answers

pyside parent of multiple uis gets destroyed if one ui closes

When I use the same parent QWidget for multiple UIs all UIs close, when one UI is closed by the user. Is there a good reason for that and a solution to keep the other UIs open, when they have the same parent? Setting "setQuitOnLastWindowClosed" to…
Rico
  • 11
  • 3
1
vote
1 answer

Why does the Irrlicht window turn black when opening a QMessageBox?

I'm using Irrlicht in a Qt context. To do this, I have an IrrlichtWidget class which shows an Irrlicht device in a QWidget. Here is the relevant part of that class: class IrrlichtWidget : public QWidget{ Q_OBJECT public: IrrlichtWidget(){ …
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
1
vote
1 answer

PYQT4: Critical Message Box

Okay, not sure what I am missing here. I have created a GUI app for work, which contains a close button. I am able to get the closeEvent function to execute, if the user uses the custom window close button. However, when they click the close button…
Jeremy Scott
  • 167
  • 1
  • 3
  • 15
1
vote
2 answers

PyQt5: QMessageBox vanishes after starting

When I invoke Error Message One (see comments in code) the message quickly appears and then vanishes. But if I invoke Error Message Two, it appears and only vanishes when I click on the 'OK' button. How can I fix it so that Error Message One works…
Ramón Wilhelm
  • 967
  • 2
  • 18
  • 39
1
vote
1 answer

PyQt5 : clarifying connect() method in QMessageBox standardButtons

first, the code scope of my trouble: from PyQt5 import QtWidgets, QtCore # I found this function on the web: def msgbtn(i): """ This function works, and returns "Ok" or "Cancel" (string object). """ print("Button pressed is:",…
glihm
  • 1,138
  • 13
  • 29
1
vote
1 answer

QDialog keeps blocking mouse input even after close

PyQt4/5 on OSX El Capitan I have a QMessageBox/QDialog which I want to be modal and want to block input from other GUI items while a process is running. The QDialog should provide the user the option to cancel the said process, but not allow him or…
Daniel Schreij
  • 773
  • 1
  • 10
  • 26