Unsolved how to show a nomber in a message box
-
#include "MaFenetre.h" MaFenetre::MaFenetre() : QWidget() { setFixedSize(600, 300); m_lcd = new QLCDNumber(this); m_lcd->setSegmentStyle(QLCDNumber::Flat); m_lcd->setGeometry(250, 20, 100, 50); m_slider = new QSlider(Qt::Horizontal, this); m_slider->setGeometry(200, 100, 200, 30); m_boutonDialogue = new QPushButton("Ouvrir la boîte de dialogue", this); m_boutonDialogue->setGeometry(200, 150, 200, 50); QObject::connect(m_slider, SIGNAL(valueChanged(int)), m_lcd, SLOT(display(int))) ; QObject::connect(m_boutonDialogue, SIGNAL(clicked()), this, SLOT(ouvrirDialogue())); } void MaFenetre::ouvrirDialogue() { QMessageBox::warning(this, "Titre de la fenêtre", "here"); }
i would like to show the number on the QLCDNumber(m_lcd) in the message box
How can i do that? -
AFAIK
QMessageBox
can only display text but noQWidgets
.
You can use aQDialog
instead. -
@arthur1000 Hi, like @Pl45m4 said - add your own class that inherits from QDialog. You have a wizard for that too. You can customise
it the way you like, add widgets etc.
Functionality similar to showing the message box can be achieved usingexec()
method.
Details and links to examples: https://doc.qt.io/qt-5/qdialog.html -
Hi,
The most simple is to use QString::arg with your QLcdNumber::value as input to build the string you pass to QMessageBox.
-
Try This
QMessageBox::information(this,"YOUR TITLE ",QString::number(m_lcd->value()));
-
@Ketan__Patel__0011
Thanks !! -
Best of luck for you project
if your problem is solved
then please Mark This post as the correct answer.