Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create frameless QMessageBox
Forum Update on Monday, May 27th 2025

Create frameless QMessageBox

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 2.7k Views
  • 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 Offline
    M Offline
    marlenet15
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      1
      • SGaistS SGaist

        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.

        M Offline
        M Offline
        marlenet15
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0
          • SGaistS SGaist

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

            M Offline
            M Offline
            marlenet15
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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
              1

              • Login

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