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. QWindow, QWidget, Qt5, X11Embedding how?
Forum Updated to NodeBB v4.3 + New Features

QWindow, QWidget, Qt5, X11Embedding how?

Scheduled Pinned Locked Moved General and Desktop
41 Posts 5 Posters 29.3k 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.
  • P Offline
    P Offline
    pratap
    wrote on last edited by
    #32

    Hi all,

    Is anyone solved the problem as i am also facing similar problem.It will good if anyone can share replacement for qx11embedcontainer in qt 5.2.

    thanks

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #33

      Hi,

      [quote author="pratap" date="1407410200"]Is anyone solved the problem as i am also facing similar problem.It will good if anyone can share replacement for qx11embedcontainer in qt 5.2.[/quote]Please read the previous posts in this thread. I posted examples on how to use QWindow::fromWinId() and QWidget::createWindowContainer() to replace QX11EmbedContainer.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratap
        wrote on last edited by
        #34

        I have checked previous posts based on that i tried to use QWindow::fromWinId() and QWidget::createWindowContainer() but its not working for me .

        below is source code

        @int main(int argc, char *argv[])
        {
        QApplication app(argc, argv);

        QVBoxLayout *vl = new QVBoxLayout;
        
        QtQuick1ApplicationViewer viewer;
        viewer.addImportPath(QLatin1String("modules"));
        viewer.setOrientation(QtQuick1ApplicationViewer::ScreenOrientationAuto);
        viewer.setMainQmlFile(QLatin1String("qml/testX11Embed/main.qml"));
        viewer.showExpanded();
        
        viewer.setLayout(vl);
        
        //getting the window id of thirdparty application
        
        system( "xwininfo -int -name 'Navigation - India' |grep 'Window id: '| awk '{gsub(\"xwininfo: Window id: \", \"\");print}' >> EmbeddingLogNavigation.txt") ;
        
        std::string sWiId;
        
        long int navigationWindowId;
        std::ifstream in("EmbeddingLogNavigation.txt");
        std::stringstream buffer;
        buffer << in.rdbuf();
        std::string contents(buffer.str());
        
        for( int i = 0 ; contents[i] != ' ' && contents[i] != '\0' ; ++i )
            sWiId += contents[i];
        
        std::stringstream sstr(sWiId);
        
        sstr >> navigationWindowId;
        

        ////////////////////////////////////////////////

        QWidget navwidget;
        navwidget.setGeometry(0 ,0,2000 ,1000);
        navwidget.resize(500,500);
        navwidget.setPalette(QPalette(QColor(0,255,0,255)));
        navwidget.setAutoFillBackground(true);
        
        navwidget.createWindowContainer(QWindow::fromWinId(navigationWindowId));
        vl -> addWidget(&navwidget);
        navwidget.show();
        
        return app.exec&#40;&#41;;
        

        }
        @

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #35

          [quote author="pratap" date="1407414917"]below is source code[/quote]Your code is too complex. Write something simpler -- don't include things that are not related to embedding.

          [quote author="pratap" date="1407414917"]
          @viewer.setLayout(vl);@
          [/quote]The viewer already has its own layout. This line will break your viewer.

          [quote author="pratap" date="1407414917"]
          @
          navwidget.createWindowContainer(QWindow::fromWinId(navigationWindowId));
          vl -> addWidget(&navwidget);
          navwidget.show();
          @
          [/quote]QWidget::createWindowContainer() is a static function that returns a pointer to your embedded window. You need to use this return value.
          @
          QWidget *emb = QWidget::createWindowContainer(QWindow::fromWinId(navigationWindowId));
          emb->show();
          @

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pratap
            wrote on last edited by
            #36

            Thanks for reply.

            I tried as you mentioned. But output is two separate windows one for viewer and one for navwidget.

            bq. Your code is too complex. Write something simpler — don’t include things that are not related to embedding.

            @int main(int argc, char *argv[])
            {
            QApplication app(argc, argv);

            QVBoxLayout *vl = new QVBoxLayout;
            
            QtQuick1ApplicationViewer viewer;
            viewer.addImportPath(QLatin1String("modules"));
                viewer.setOrientation(QtQuick1ApplicationViewer::ScreenOrientationAuto);
            viewer.setMainQmlFile&#40;QLatin1String("qml/testX11Embed/main.qml"&#41;);
            viewer.showExpanded();
            
            long int navigationWindowId; // Window Id of navigation application
            

            // I have to embed this window into viewer window.I am able to get window id using system call.

            // Code for embedding

            QWidget *navwidget = QWidget::createWindowContainer(QWindow::fromWinId(navigationWindowId));
            vl->addWidget(navwidget);
            navwidget->show();

            @
            Output of this is two separate windows as mentioned above. Please guide me where i am doing wrong? i am using is default Qml project here provided by Qt creator(just for information).

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #37

              [quote]Output of this is two separate windows as mentioned above.[/quote]You need to put both widgets in the same layout, and embed the layout in a blank widget.

              @
              QtQuick1ApplicationViewer *viewer = new QtQuick1ApplicationViewer;
              // (Initialize the viewer)
              // ...

              QWidget *navwidget = QWidget::createWindowContainer(QWindow::fromWinId(navigationWindowId));

              QVBoxLayout *vl = new QVBoxLayout;
              vl->addWidget(viewer);
              vl->addWidget(navwidget);

              QWidget w;
              w.setLayout(vl);
              w.show();
              @

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pratap
                wrote on last edited by
                #38

                Thanks for helping me but its not working for me.I am getting following errors.

                QXcbConnection: XCB error: 3 (BadWindow), sequence: 250, resource id: 60817411, major code: 18 (ChangeProperty), minor code: 0
                QXcbConnection: XCB error: 3 (BadWindow), sequence: 332, resource id: 60817411, major code: 7 (ReparentWindow), minor code: 0
                QXcbConnection: XCB error: 3 (BadWindow), sequence: 334, resource id: 60817411, major code: 8 (MapWindow), minor code: 0
                QXcbConnection: XCB error: 3 (BadWindow), sequence: 367, resource id: 60817411, major code: 18 (ChangeProperty), minor code: 0
                QXcbConnection: XCB error: 3 (BadWindow), sequence: 368, resource id: 60817411, major code: 12 (ConfigureWindow), minor code: 0

                I am clueless where i am doing wrong.If you can share any example code will be great help.

                1 Reply Last reply
                0
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #39

                  [quote author="pratap" date="1407502698"]Thanks for helping me but its not working for me.I am getting following errors.

                  QXcbConnection: XCB error: 3 (BadWindow), sequence: 250, resource id: 60817411, major code: 18 (ChangeProperty), minor code: 0
                  QXcbConnection: XCB error: 3 (BadWindow), sequence: 332, resource id: 60817411, major code: 7 (ReparentWindow), minor code: 0
                  QXcbConnection: XCB error: 3 (BadWindow), sequence: 334, resource id: 60817411, major code: 8 (MapWindow), minor code: 0
                  QXcbConnection: XCB error: 3 (BadWindow), sequence: 367, resource id: 60817411, major code: 18 (ChangeProperty), minor code: 0
                  QXcbConnection: XCB error: 3 (BadWindow), sequence: 368, resource id: 60817411, major code: 12 (ConfigureWindow), minor code: 0
                  [/quote]Have you checked the value of your Window ID? Is it correct?

                  [quote]I am clueless where i am doing wrong.If you can share any example code will be great help.[/quote]Huh? I've posted so many pieces of code in this thread

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    pratap
                    wrote on last edited by
                    #40

                    Yes window ID is correct. I am able to embed Qml into Qt widget but other way it is not happening. I am getting errors as mentioned above.

                    1 Reply Last reply
                    0
                    • _ Offline
                      _ Offline
                      _Rayman_
                      wrote on last edited by
                      #41

                      I'd like to jump into this topic. I'm currently migrating our Qt4 code that heavily relies on window embedding to Qt 5.3.

                      In Qt 4 the classes QX11EmbedContainer and QX11EmbedWidget exposed several signals such as void clientClosed (), void clientIsEmbedded (), void containerClosed () etc.

                      The new mechanism in Qt5 doesn't have those signals. What are the signal equivalents in Qt5 to get informed when a client has been embedded or closed?

                      Thanks!

                      1 Reply Last reply
                      0

                      • Login

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