qmessagebox

Check for a QMessageBox and close it

让人想犯罪 __ 提交于 2019-12-23 05:27:07
问题 I need to automate gui tests in c++ qt using qtest (in eclipse) I have given a function that adds some tabs to a tabwidget (up to max 9) and if you try to open a 10th tab, a QMessageBox appears: QMessageBox::critical(this, "MAX9", tr("Only a maximum of 9 tabs can be opened.\n")); Because the whole menu with the "add tab" function and everything is private, I had to access the method using slots and signals from my testclass. Now my question is, is there a way I can check whether there are ANY

Setting parent for a QMessageBox

橙三吉。 提交于 2019-12-22 08:33:01
问题 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 ? 回答1: Probably a few things. First of all QMessageBox inherits from QDialog . Since QDialog has a concept of a parent, QMessageBox should too for consistency. Specifically, the documentation says: parent is passed to the QDialog constructor. At the very

How can i show MessageBox in another thread Qt

折月煮酒 提交于 2019-12-22 04:14:10
问题 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())); return a.exec(); } TestClass.h class TestClass: public QObject { Q_OBJECT public slots: void something() { TestThread *thread = new TestThread; thread -> start(); } }; TestThread.h class TestThread: public QThread { Q_OBJECT protected: void run() { sleep(1000); QMessageBox

Yes/No message box using QMessageBox

我的梦境 提交于 2019-12-20 08:20:52
问题 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: 回答1: You would use QMessageBox::question for that. Example in a hypothetical widget's slot: #include <QApplication> #include <QMessageBox> #include <QDebug> // ... void MyWidget::someSlot() { QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Test", "Quit?", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { qDebug(

Yes/No message box using QMessageBox

回眸只為那壹抹淺笑 提交于 2019-12-20 08:20:26
问题 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: 回答1: You would use QMessageBox::question for that. Example in a hypothetical widget's slot: #include <QApplication> #include <QMessageBox> #include <QDebug> // ... void MyWidget::someSlot() { QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Test", "Quit?", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { qDebug(

PyQt5: QMessageBox vanishes after starting

与世无争的帅哥 提交于 2019-12-20 07:27:05
问题 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 like Error Message Two? try: connection = pymysql.connect(host = 'localhost', user = 'root', db = 'Telephon Register', cursorclass = pymysql.cursors.DictCursor) cur = connection.cursor() if number!= "": cur.execute("SELECT Number FROM formen WHERE

closing pyqt messageBox with closeevent of the parent window

你。 提交于 2019-12-12 09:23:09
问题 I have folllowing piece of cake def __init__(): self._taskInProgress = threading.Event() def isFinished(self): self._taskInProgress.clear() self.progressBar.hide() self.close() def closeEvent(self, event): if self._taskInProgress.is_set(): reply = QtGui.QMessageBox.question(self, "Are you sure you want to quit? ", "Task is in progress !", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: event.accept() else: event.ignore() the problem is if somebody closes the

Issue with qmessagebox, can't change its position

梦想的初衷 提交于 2019-12-12 04:18:47
问题 I have this int MainWindow::messageBox( QString button, QMessageBox::ButtonRole buttons, QString info, QMessageBox::Icon icon ) { QFont f; f.setPointSize(6); QMessageBox *message = new QMessageBox(this); message->setWindowModality(Qt::WindowModal); message->setFont(f); message->setText(info); message->addButton( button, buttons ); message->setWindowTitle("MainWindow"); message->setIcon(icon); message->move( this->width() / 2, this->height() / 2 ); return message->exec(); } But I can't make

Display QMessageBox with multiple arguments

只谈情不闲聊 提交于 2019-12-11 09:07:53
问题 I'm using the Qt framework and I'm a little rusty with it. I have two QStrings first and last I want to display them in a QMessageBox but don't know how to include multiple arguments. This is what I have to code it with on argument: QMessageBox::information(0, "Full Name", QString("%1 %2").arg(first)); How do I get the other argument ( last ) included in that output? 回答1: All of the arg()s return a QString so the following should work: QMessageBox::information(0, "Full Name", QString("%1 %2")

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

余生颓废 提交于 2019-12-10 15:26:20
问题 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 frame -> Close disabled). Here is some sample code: QMessageBox box(QMessageBox::Critical, title, text, QMessageBox::Ok); box.setDetailedText(detailedText); // comment this line to get close button enabled box.exec(); I didn't even find a way to