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
5
votes
1 answer

How to center text and buttons in QMessageBox widget

I'm making a QMessageBox and was having trouble centering the text and the buttons in the pop up window. This is the code that I have for the message box: def update_msgbox(self): self.msg = QMessageBox(self.centralwidget) …
yem
  • 529
  • 1
  • 6
  • 20
5
votes
1 answer

How to change icon in title QMessageBox in Qt, python

How to change or delete icon in title QMessageBox in Qt, python. I have next cod: msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, ' ', 'Completed', …
Teit
  • 53
  • 1
  • 1
  • 4
5
votes
3 answers

QMessageBox delete on close

I have a question that has obvious answer for some of you, but I just can't figure it out. QMessageBox http://qt-project.org/doc/qt-5/qmessagebox.html has 2 ways of being displayed, either you do exec() which stop the program execution until user…
Petr
  • 13,747
  • 20
  • 89
  • 144
5
votes
3 answers

How to change font of a QMessageBox in Qt?

I was trying to build a simple application with a QComboBox and a QPushButton. The idea is to populate the QComboBox with a list of all available fonts in the system. When the user selects a font and presses the QPushButton then a QMessageBox…
sabertooth1990
  • 1,048
  • 1
  • 13
  • 19
5
votes
2 answers

How to subclass QMessageBox and add a progress bar in PySide

I'm rather new to PySide, and Qt in general. I want to add a QProgressBar to a QMessageBox where the buttons would usually be. I'm hoping that there's some way to subclass QMessageBox and change it's layout, but I've never done a Qt layout in code,…
chyyran
  • 2,446
  • 2
  • 21
  • 35
5
votes
2 answers

Subclassing QMessageBox

I need to customize QMessageBox. I need to remove the frame and title bar and add my own title bar and close button. Also need to replace the standard buttons and probably redo the background color of the box. Is it possible to subclass it and…
go4sri
  • 1,490
  • 2
  • 15
  • 29
5
votes
2 answers

Qt::Sheet and QMessageBox::show() on Mac

I have an application where I want to ask the user a question in a QMessageBox and then respond accordingly. The problem is that on a Mac I want the dialog to show up as a Sheet, but using the open() method returns immediately. QMessageBox* msgBox =…
Addy
  • 2,414
  • 1
  • 23
  • 43
4
votes
5 answers

Setting parent for a QMessageBox

i can't understand what's the benefit of setting parent for a QMessageBox, for instance in the following code: void mainWindow::showMessage(QString msg) { QMesageBox::information(this, "title", msg); //'this' is parent } can somebody help me ?
s4eed
  • 7,173
  • 9
  • 67
  • 104
4
votes
1 answer

Check which button in an QMessageBox was clicked

How should I check which one of the buttons in the following QMessageBox was clicked? The button == QMessageBox.Ok is not working. class WarningWindow(QMessageBox): nextWindowSignal = pyqtSignal() def __init__(self): …
dvilela
  • 1,200
  • 12
  • 29
4
votes
1 answer

Can an icon be centered over text in a QMessageBox?

I am new to Qt, and am having fun diving in by building up an application in it. I have produced the below QMessageBox as a response to the About MyGreatApp menu item, which you can see has both an icon and text. Can icon and text be positioned…
Alexis
  • 784
  • 8
  • 32
4
votes
1 answer

How to display variable in qmessagebox using creator in pyqt5

I am trying to display a variable with some message in qmessagebox using creator. I found similar post here: pyqt: Variable values in QMessageBox output? but it does not work within the creator. Any suggestions how to amend the code below so that it…
New2coding
  • 715
  • 11
  • 23
4
votes
3 answers

How change font color for QMessageBox Label's?

What I mean QMessageBox::question, QMessageBox::warning, QMessageBox::critical, QMessageBox::Information { /* Base Text Size & Color */ font-size:12px; color:#ffffff; } If I try QmessageBox .QLabel it's change font for all form/windows end how add…
tseries
  • 723
  • 1
  • 6
  • 14
4
votes
1 answer

Python QMessageBox new line '\n' and link broken

I have a QMessageBox and want to create a link on a new line. I cannot get the link to work when I use \n link = "www.google.com" msg = "This works: Google" % link reply = QMessageBox.information(self, 'Message', msg,…
user1408329
  • 53
  • 1
  • 6
4
votes
2 answers

pyqt: messagebox automatically closing after few seconds

I am trying to do a warning message box that disappears automatically after few seconds. I have done this code: def warning(self): messagebox = QtGui.QMessageBox(self) messagebox.setWindowTitle("wait") messagebox.setText("wait (closing…
p.deman
  • 584
  • 2
  • 10
  • 24
4
votes
2 answers

How can I get access to a QMessageBox by QTest

I am creating some automated GUI tests in my application using QTest. I can access the widgets from my application using the command: savePushButton = mainWindow->findChild("savePushButton"); It is working fine, but now I have to…
KelvinS
  • 2,870
  • 8
  • 34
  • 67
1
2
3
15 16