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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Out of scope
    • Affects Version/s: 5.4.1
    • Fix Version/s: None
    • Component/s: GUI: Window management
    • Labels:
      None
    • Environment:
      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

        1. CreateInContainer.png
          CreateInContainer.png
          22 kB
        2. CreateInContainer-2.png
          CreateInContainer-2.png
          25 kB
        3. CreateInContainer-click on combobox.png
          CreateInContainer-click on combobox.png
          19 kB
        4. CreateInContainer-move then click on combobox.png
          CreateInContainer-move then click on combobox.png
          19 kB
        5. qtbug45275_orig.zip
          4 kB
        6. Reparenting.7z
          2 kB

          Issue Links

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

            Activity

              People

              • Assignee:
                kleint Friedemann Kleint
                Reporter:
                r1z1 Erwan
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes