Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-45275

Wrong display with foreign widget with QWidget::createWindowContainer()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.4.1
    • GUI: Window management
    • None
    • Windows 7 - x64
      Qt5.4.1

    Description

      I want to use the QWidet::createWindowContainer to reparenting a QWidget from another process to my "main" application.

      In the sample i used the createInContainer with a QWidget created outside the application and with a QWidget created inside the application. The createInContainer works when the widget is created in the application but when the widget comes from another application the display is wrong.

      Create the independent window in process A
      	// Create the independent window -------------------------------
      	QWidget* widget = new QWidget();
      	widget->setWindowTitle(MY_TITLE);
      	widget->setAttribute( Qt::WA_DeleteOnClose );
      	widget->setAttribute(Qt::WA_NativeWindow, true);
      	widget->setAttribute(Qt::WA_NoSystemBackground, true);
      	widget->setAutoFillBackground(false);
      
      	QVBoxLayout *verticalLayout( new QVBoxLayout(widget) );
      
      	QComboBox* combo = new QComboBox(widget);
      	combo->addItem("Combobox create outside this app - 1");
      	combo->addItem("Combobox create outside this app - 2");
      	verticalLayout->addWidget(combo);
      
      	widget->show();
      
      Get the independent window in container: Process B
      	// Find the independent window -------------------------------
      	TCHAR* tTitle = (TCHAR*)MY_TITLE.utf16();
      	WId myWidgetId = (WId)::FindWindow(0, tTitle);
      	//------------------------------------------------------------
      
      	QWindow* window = QWindow::fromWinId(myWidgetId);
      	QWidget* container = QWidget::createWindowContainer(window);
      	container->setFocusPolicy(Qt::TabFocus);
      	container->setMinimumSize(100,50);
      	ui->verticalLayout->addWidget(container);
      

      The Qwidget from process A is embedded in the process B but:

      • the initial display is wrong

      • wrong display on combobox click
      • after moving the window

      Sample Source code attached but works only for windows:

      • Run MyWidget First
      • Then run CreateInContainer
        (The application won't shut down after closing the window, i didn't find a solution for that)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              r1z1 Erwan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes