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. A pop-up window cannot be added into a layout?
Forum Updated to NodeBB v4.3 + New Features

A pop-up window cannot be added into a layout?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 535 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.
  • L Offline
    L Offline
    Lee908
    wrote on last edited by
    #1

    Hi,

    I have a pop-up window and I add it into a layout so that it can always be located at the top-right conner of parent window. But I find that the pop-up flag is missing after it's added into layout.

    So, my question is that pop-up window cannot be added into a layout? If that, how to make sure the pop-up window always located at a specific position? Thanks in advance.

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      Without knowing you exact constellation: A popup is a separate window by definition. If put in a parent‘s layout, it’s no longer a popup.
      If that hasn’t answered your question: What exactly is that popup? Which class? How should it behave?

      Software Engineer
      The Qt Company, Oslo

      L 1 Reply Last reply
      3
      • Axel SpoerlA Axel Spoerl

        Without knowing you exact constellation: A popup is a separate window by definition. If put in a parent‘s layout, it’s no longer a popup.
        If that hasn’t answered your question: What exactly is that popup? Which class? How should it behave?

        L Offline
        L Offline
        Lee908
        wrote on last edited by Lee908
        #3

        @Axel-Spoerl

        There is a qwidget, which is added into a layout to locate at the top right corner of main window. My requirement is that qwidget is shown when click an icon and hidden when click that icon again or click out of the qwidget. So I set it 'pop-up' flag by calling setWindowsFlag(Qt::Popup | Qt::FramelessWindowHInt). But it doesn't work. I view the property and find the Qt::Popup flag is gone away in the gammaray.

        If put in a parent‘s layout, it’s no longer a popup.

        If that, how to achieve pop-up behavior for the qwidget in a layout?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          You use QWidget::hide() and QWidget::show() to make the widget do those things. If it is in a layout then the other widgets may rearrange when you change the visibility.

          If the intent is that the "pop-up" floats over the top of content then it should not be in the layout and you have to position it yourself with QWidget::move(). The "pop-up" should have a parent widget. You would use something like this to position it top-right:

          Q_ASSERT(popup->parent());
          popup->move( popup->parent()->width() - popup-width(), 0);
          
          L 1 Reply Last reply
          2
          • C ChrisW67

            You use QWidget::hide() and QWidget::show() to make the widget do those things. If it is in a layout then the other widgets may rearrange when you change the visibility.

            If the intent is that the "pop-up" floats over the top of content then it should not be in the layout and you have to position it yourself with QWidget::move(). The "pop-up" should have a parent widget. You would use something like this to position it top-right:

            Q_ASSERT(popup->parent());
            popup->move( popup->parent()->width() - popup-width(), 0);
            
            L Offline
            L Offline
            Lee908
            wrote on last edited by
            #5

            @ChrisW67

            Thanks for your reply. If use hide(), how to get the timing right to call it when click out of the widget? And if use popup->move() to locate the widget, do I need update the position when parent window's position or size is changed? How to get that timing right?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by ChrisW67
              #6

              @Lee908 said in A pop-up window cannot be added into a layout?:

              If use hide(), how to get the timing right to call it when click out of the widget?

              Before you waste too much more effort here. Take a look at the Window Flags Example and see what the popup does by default.

              And if use popup->move() to locate the widget, do I need update the position when parent window's position or size is changed? How to get that timing right?

              The child widget is placed in coordinates within the parent. If the parent moves then its child widgets go with it. If the parent resizes then child widgets that are part of layout are automatically adjusted. Everything else is done manually, perhaps in the parent widget's resize event.

              Generally, to resize the parent window the user will have clicked outside the popup already. It may be there is nothing to reposition.

              1 Reply Last reply
              3

              • Login

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