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
131
votes
8 answers

Yes/No message box using QMessageBox

How do I show a message box with Yes/No buttons in Qt, and how do I check which of them was pressed? I.e. a message box that looks like this:
sashoalm
  • 75,001
  • 122
  • 434
  • 781
26
votes
5 answers

How can I resize QMessageBox?

I have a QMessageBox which I'd like it to be bigger. It's a simple QMessageBox with two standard buttons, Ok and Cancel. The problem is that it is very small for my application's purposes. Code shows like this: QMessageBox…
DYangu
  • 611
  • 1
  • 7
  • 16
21
votes
2 answers

HTML in QMessageBox

I have an action which create QMessageBox. In that dialog I want to print a list, which contains several items. I have the following code: void MainWindow::onAboutActivated(){ qDebug() << "about"; QMessageBox::about(this, "Autor:…
Jan
  • 1,054
  • 13
  • 36
18
votes
2 answers

QMessageBox change text of standard button

I want to use QMessageBox.Question for the icon. But i want to change the text of standard buttons. I do not want the text of buttons to be the "Yes" and "No". I want them to be "Evet" and "Iptal". Here my codes. choice =…
Taylan
  • 736
  • 1
  • 5
  • 14
12
votes
3 answers

QMessageBox "show details"

When you open a QMessageBox with detailed text set it has the show details button. I would like the details to be displayed by default, rather than the user having to click on the Show Details... button first.
UmNyobe
  • 22,539
  • 9
  • 61
  • 90
11
votes
1 answer

QMessageBox with a "Do not show this again" checkbox

How can I show a message box with a "Do not show again" checkbox below? I imagine something that looks like this:
user5820174
  • 151
  • 1
  • 12
10
votes
1 answer

How can i show MessageBox in another thread Qt

That's my code for this: int main(int argc, char *argv[]) { QApplication a(argc, argv); testApp w; w.show(); TestClass *test = new TestClass; QObject::connect(w.ui.pushButton, SIGNAL(clicked()), test, SLOT(something())); …
Alexander Mashin
  • 693
  • 3
  • 14
  • 34
10
votes
1 answer

How to display a QMessageBox on top of all windows

I have created a program that runs alongside an application in fullscreen. I would like the QMessageBox from my program to be displayed on top of the application that runs in fullscreen. The platform is Windows 7 and i am using Qt. I have…
Nicolai Lissau
  • 7,298
  • 5
  • 43
  • 57
9
votes
3 answers

How to Change QMessageBox Icon and Title

I am creating a ui app with Qt c++. I have a error message that I have created by using QMessageBox Class like : QMessageBox errorMessage; errorMessage.critical(0, "Error", "An error has occured !"); errorMessage.setFixedSize(500, 200); It is…
BUY
  • 705
  • 1
  • 11
  • 30
9
votes
2 answers

PyQt5 - How to add a scrollbar to a QMessageBox

I have a list which is generated based on user-input. I am trying to display this list in a QMessageBox. But, I have no way of knowing the length of this list. The list could be long. Thus, I need to add a scrollbar to the…
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
8
votes
4 answers

What determines the default title for a QMessageBox?

I want to change the default QMessageBox title to something else, so that I don't have to call setWindowTitle for every individual message box. How is the default window title chosen?
Pieter
  • 31,619
  • 76
  • 167
  • 242
8
votes
3 answers

Problem with hidden QMainWindow: application crashes after QMessageBox is displayed

// main.cpp #include #include "mainwindow.h" int main(int argc, char* argv[]) { QApplication app(argc, argv); MainWindow* window = new MainWindow(); window->show(); return app.exec(); } // mainwindow.cpp #include…
Andrey Moiseev
  • 3,914
  • 7
  • 48
  • 64
8
votes
6 answers

Auto close QMessageBox

I'm building a Qt Symbian Project and I want to show a notification for the user that should auto close after some seconds. I have seen that Nokia uses this a lot in their ui. Right now I'm using the code below so that the user can close the…
Martin
  • 1,675
  • 11
  • 34
  • 46
7
votes
4 answers

QMessageBox is not displaying whole title

#include int main(int argc, char** argv) { QApplication app(argc, argv); // first QMessageBox box(0); box.setText("short text"); box.setWindowTitle("looooooooooooooooong text"); box.setMinimumSize(800, 0); …
Ashot
  • 10,807
  • 14
  • 66
  • 117
6
votes
3 answers

Adding detailed text in QMessageBox makes close (X) button disabled

I noticed an interesting thing - if I add a detailed text to QMessageBox (which adds "Show Details..." button) then executing it will show the system frame's close (X) button disabled and hence marking this window as non-closable (right click on…
frangulyan
  • 3,580
  • 4
  • 36
  • 64
1
2 3
15 16