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. Problem with position of widget created with QWidget::createWindowContainer.

Problem with position of widget created with QWidget::createWindowContainer.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k 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.
  • N Offline
    N Offline
    never_ever
    wrote on last edited by
    #1

    Hi,

    I have main window where I have QWidget container named widget, It was created in QtCreator. That widget should be a parent of my other widget that I create using QWidget::createWindowContainer.

    @

    void MainClass::createWidgetFromId(WId id)
    {
    cWindow = QWindow::fromWinId(id); // QWindow* cWindow;
    cWidget = QWidget::createWindowContainer(cWindow); // QWidget* cWidget;
    cWidget->setParent(ui->widget);
    cWidget->show();
    }

    @

    That cWidget has position (0,0) (absolute position, in relation to the main window). It should have (0,0) position but in relation to its parent. Parent has position (0,20) in relation to the main window.
    Any idea what is causing that problem?

    1 Reply Last reply
    0
    • xwangX Offline
      xwangX Offline
      xwang
      wrote on last edited by xwang
      #2

      Hi,maybe it's too late to answer. Once i have also used createWindowContainer,and found the cWidget's position is (0,0). Finnaly I have found this linke -> stackoverflow. try

      	cWindow->setFlags(Qt::FramelessWindowHint);
      

      and it is better to use QHBoxLayout to manager cWidget and this

      cWindow = QWindow::fromWinId(id);
      cWindow->setFlags(Qt::FramelessWindowHint);
      cWidget = QWidget::createWindowContainer(cWindow);
      QHBoxLayout *layout = new QHBoxLayout(this);
      layout->addWidget(cWidget);
      this->addLayout(layout);
      cWidget->show();
      
      1 Reply Last reply
      2

      • Login

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