Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MessageBox closing Error ?
Qt 6.12 LTS is out! See what's new in the release blog

MessageBox closing Error ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 601 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ramkumar MohanR Offline
    Ramkumar MohanR Offline
    Ramkumar Mohan
    wrote on last edited by
    #1

    I wrote this code , and i'm pressing the back button on the messagebox doesn't close the mesagebox but shows the messagebox again. A second click closes the messagebox.

    QMessageBox msg(this);
    msg.setWindowFlags( Qt::Window | Qt::FramelessWindowHint);
    msg.setStyleSheet("font: 75 20pt Liberation Serif ;");
    QPixmap p("/home/pi/git/Updates/UI/img/Shield.png");
    auto newPixmap = p.scaled(80, 80);
    msg.setIconPixmap(newPixmap);
    QFont font;
    font.setBold(true);
    msg.setFont(font);
    msg.setText(" Quality Check - 405 nm \n\n Run Distilled Water");
    msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msg.setButtonText(QMessageBox::Ok , "Run");
    msg.setButtonText(QMessageBox::Cancel , "Back");
    msg.setFixedWidth(500);
    if(msg.exec() == QMessageBox::Ok)
    {
    ui->stackedWidget->setCurrentIndex(1);
    }
    else
    {
    ui->stackedWidget->setCurrentIndex(1);
    }

    The messagebox should be closed on the first click.
    how to write it?

    JonBJ 1 Reply Last reply
    0
    • Ramkumar MohanR Ramkumar Mohan

      I wrote this code , and i'm pressing the back button on the messagebox doesn't close the mesagebox but shows the messagebox again. A second click closes the messagebox.

      QMessageBox msg(this);
      msg.setWindowFlags( Qt::Window | Qt::FramelessWindowHint);
      msg.setStyleSheet("font: 75 20pt Liberation Serif ;");
      QPixmap p("/home/pi/git/Updates/UI/img/Shield.png");
      auto newPixmap = p.scaled(80, 80);
      msg.setIconPixmap(newPixmap);
      QFont font;
      font.setBold(true);
      msg.setFont(font);
      msg.setText(" Quality Check - 405 nm \n\n Run Distilled Water");
      msg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
      msg.setButtonText(QMessageBox::Ok , "Run");
      msg.setButtonText(QMessageBox::Cancel , "Back");
      msg.setFixedWidth(500);
      if(msg.exec() == QMessageBox::Ok)
      {
      ui->stackedWidget->setCurrentIndex(1);
      }
      else
      {
      ui->stackedWidget->setCurrentIndex(1);
      }

      The messagebox should be closed on the first click.
      how to write it?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Ramkumar-Mohan
      Please learn to put blocks of code inside Code tags to make it easier for others to read, thank you.

      Use a debugger/qDebug() statements to verify it returns on first click and follows the else route in your code. Assuming so, what happens after that?

      Ramkumar MohanR 1 Reply Last reply
      0
      • JonBJ JonB

        @Ramkumar-Mohan
        Please learn to put blocks of code inside Code tags to make it easier for others to read, thank you.

        Use a debugger/qDebug() statements to verify it returns on first click and follows the else route in your code. Assuming so, what happens after that?

        Ramkumar MohanR Offline
        Ramkumar MohanR Offline
        Ramkumar Mohan
        wrote on last edited by
        #3

        @JonB Ok Thank you.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved