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. Non-modal Qt::Popup
QtWS25 Last Chance

Non-modal Qt::Popup

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 7.3k 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.
  • C Offline
    C Offline
    cidadao
    wrote on 8 Aug 2017, 08:33 last edited by
    #1

    Hello,

    I want to have a QWidget with Qt::Popup window flag. But it needs to be non-modal. Even if I set modality to Qt::NonModal, after setting the windows flags, the popup always blocks interaction with the parent.

    Is this a bug? A feature? What's a workaround for this?

    I'm on Windows.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vinod Kuntoji
      wrote on 8 Aug 2017, 10:05 last edited by Vinod Kuntoji 8 Aug 2017, 10:23
      #2

      @cidadao ,

      Widget::Widget(QWidget *parent) :
      QWidget(parent),
      ui(new Ui::Widget)
      {
      ui->setupUi(this);
      m_Button = new QPushButton(this);
      sample = new QWidget;
      sample->setAttribute( Qt::WA_QuitOnClose, false );
      if(sample->isMinimized()) {
      sample->showNormal();
      }
      connect(m_Button,SIGNAL(clicked()),this,SLOT(on_pushButton_Clicked()));
      }
      void Widget::on_pushButton_clicked()
      {
      sample->setFixedSize(50,50);
      sample->setWindowFlags(Qt::FramelessWindowHint);
      sample->setWindowModality(Qt::NonModal);
      sample->show();
      }

      C++, Qt, Qt Quick Developer,
      PthinkS, Bangalore

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cidadao
        wrote on 8 Aug 2017, 15:28 last edited by
        #3

        @Vinod-Kuntoji it really has to be a Popup, not a FramelessWindow. A Popup doesn't take space in a layout, it is drawn on top other widgets instead.

        If you try your code with Qt::Popup you might have the same problem as OP (can't set a Popup to be non-modal)

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pablo J. Rogina
          wrote on 8 Aug 2017, 18:45 last edited by
          #4

          @cidadao it looks like you want a green ball that is red...

          From Qt documentation about Qt::Popup window type enum:
          "Indicates that the widget is a pop-up top-level window, i.e. that it is modal, but has a window system frame appropriate for pop-up menus."

          so modal it'll be...

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          3
          • C Offline
            C Offline
            cidadao
            wrote on 9 Aug 2017, 12:05 last edited by
            #5

            @Pablo-J-Rogina got it! Modal forever :)
            Still wondering if this OS-specific or just a design choice on Qt's implemantation though.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              cidadao
              wrote on 11 Aug 2017, 12:58 last edited by
              #6

              Finally, the exact answer I was looking for:

              Qt::FramelessWindowHint | Qt::Tool
              

              Instead of using Qt::Popup.

              1 Reply Last reply
              2

              6/6

              11 Aug 2017, 12:58

              • Login

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