Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Create frameless QMessageBox

    General and Desktop
    2
    6
    2201
    Loading More Posts
    • 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.
    • M
      marlenet15 last edited by

      I have an application which is constructed as a stackwidget. When the user presses a button, a QMessageBox will pop up. I would like to take off the title of the messagebox. However, when the button is pressed, the messagebox appears BUT the application closes. What do I need to change?

      void user_Data::onClickButton()
      {
          QMessageBox *mb;
          mb->setWindowFlags(Qt::FramelessWindowHint |Qt::WindowStaysOnTopHint);
          mb->question(this,tr("TITLE"),tr("Are you sure you want to do this?"));
      }
      
      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Two options:

        1. Allocate mb on the stack
        2. Initialize mb properly (don't forget to delete it when you're done using it.)

        Warning: question is a static method, so currently you're using it wrongly.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply Reply Quote 1
        • M
          marlenet15 @SGaist last edited by

          @SGaist I am not sure I follow you. How would I initialize mb properly? Oops, yes it is a warning.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Well: you have to allocate it since you're declaring a pointer to it.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            M 1 Reply Last reply Reply Quote 0
            • M
              marlenet15 @SGaist last edited by

              @SGaist Ok so the Application doesn't close anymore but the QMessageBox keeps showing the title bar.

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Again: question is a static method, it won't make use of any of your settings.

                Take a look at the Property based API chapter of QMessageBox documentation.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post