Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Widget can't move after set the windowFlag to Qt::Window
QtWS25 Last Chance

Widget can't move after set the windowFlag to Qt::Window

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
4 Posts 2 Posters 376 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.
  • G Offline
    G Offline
    Gaobo
    wrote on 7 Dec 2023, 06:58 last edited by
    #1

    hello, I have some question about WebAssembly.
    I create a widget, and set windowFlag to Qt::Window. Then show it, why it show at top left of the browser, and i can't move it.
    my code is:

    Form::Form(QWidget *parent)
        : QWidget(parent)
        , ui(new Ui::Form)
    {
        ui->setupUi(this);
    
        this->setWindowFlags(Qt::Window);
        this->installEventFilter(this);
    }
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
    
        auto f = new Form(this);
        f->move(200, 200);
        f->show();
    }
    
    

    1724df75-ed2f-42e7-ae86-a993280f5904-image.png

    G J 2 Replies Last reply 7 Dec 2023, 09:22
    0
    • G Gaobo
      7 Dec 2023, 06:58

      hello, I have some question about WebAssembly.
      I create a widget, and set windowFlag to Qt::Window. Then show it, why it show at top left of the browser, and i can't move it.
      my code is:

      Form::Form(QWidget *parent)
          : QWidget(parent)
          , ui(new Ui::Form)
      {
          ui->setupUi(this);
      
          this->setWindowFlags(Qt::Window);
          this->installEventFilter(this);
      }
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
      
          auto f = new Form(this);
          f->move(200, 200);
          f->show();
      }
      
      

      1724df75-ed2f-42e7-ae86-a993280f5904-image.png

      G Offline
      G Offline
      Gaobo
      wrote on 7 Dec 2023, 09:22 last edited by
      #2

      when i set Qt::Dialog to windowFlat, widget become moveable. why?
      then it have another question:
      the widget can never be showed

      1 Reply Last reply
      0
      • G Gaobo
        7 Dec 2023, 06:58

        hello, I have some question about WebAssembly.
        I create a widget, and set windowFlag to Qt::Window. Then show it, why it show at top left of the browser, and i can't move it.
        my code is:

        Form::Form(QWidget *parent)
            : QWidget(parent)
            , ui(new Ui::Form)
        {
            ui->setupUi(this);
        
            this->setWindowFlags(Qt::Window);
            this->installEventFilter(this);
        }
        
        MainWindow::MainWindow(QWidget *parent)
            : QMainWindow(parent)
            , ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        
        
            auto f = new Form(this);
            f->move(200, 200);
            f->show();
        }
        
        

        1724df75-ed2f-42e7-ae86-a993280f5904-image.png

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 8 Dec 2023, 07:35 last edited by
        #3

        @Gaobo said in Widget can't move after set the windowFlag to Qt::Window:

        Then show it, why it show at top left of the browser, and i can't move it

        Because it is not a window - it has a parent (MainWindow), so it is part of main window. If you want to show it as a window then do not set a parent.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        G 1 Reply Last reply 9 Dec 2023, 01:22
        0
        • J jsulm
          8 Dec 2023, 07:35

          @Gaobo said in Widget can't move after set the windowFlag to Qt::Window:

          Then show it, why it show at top left of the browser, and i can't move it

          Because it is not a window - it has a parent (MainWindow), so it is part of main window. If you want to show it as a window then do not set a parent.

          G Offline
          G Offline
          Gaobo
          wrote on 9 Dec 2023, 01:22 last edited by
          #4

          @jsulm
          thanks;

          If you want to show it as a window then do not set a parent.

          Under windows, it show as a window when i not set parent for form. but under web(browser), it doesn't show. why?

          What difference between Qt::window and Qt::widget?

          when i set Qt::Dialog to windowFlat, widget become moveable. why?

          and i set it to dialog and set parent, form can normally show and move. why?

          1 Reply Last reply
          0
          • G Gaobo has marked this topic as solved on 19 Feb 2024, 09:58

          1/4

          7 Dec 2023, 06:58

          • Login

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