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. How to resize XEmbed in Qt5 with window size change
Forum Updated to NodeBB v4.3 + New Features

How to resize XEmbed in Qt5 with window size change

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 976 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.
  • D Offline
    D Offline
    devqore
    wrote on last edited by
    #1

    Hi,
    I'm trying to resize external application which is attached to application using QWidget::createWindowContainer for simplicity in example xterm is used:

    #include <QApplication>
    #include <QWidget>
    #include <QVBoxLayout>
    #include <QWindow>
    #include <QProcess>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QWidget widget;
        QWindow window;
        QWidget *container = QWidget::createWindowContainer(&window, &widget);
        QVBoxLayout layout;
        QProcess process;
        QStringList arguments;
        
        layout.addWidget(container);
        widget.setLayout(&layout);
        widget.show();
        arguments << "-into" << QString::number(container->winId());  // also doesn't work properly with window.winId()
        process.start("xterm", arguments);
    
        return app.exec();
    }
    

    And in this example xterm is not resized when main widget is resized, following example works in Qt4 with QX11EmbedContainer:

    #include <QApplication>
    #include <QWidget>
    #include <QX11EmbedContainer>
    #include <QVBoxLayout>
    #include <QProcess>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QWidget widget;
        QX11EmbedContainer container(&widget);
        QVBoxLayout layout;
        QProcess process;
        QStringList arguments;
    
        layout.addWidget(&container);
        widget.setLayout(&layout);
        widget.show();
        arguments << "-into" << QString::number(container.winId());
        process.start("xterm", arguments);
    
        return app.exec();
    }
    

    Does anybody have idea how I can achieve such effect in Qt5 like in Qt4 with QX11EmbedContainer? Any tips will be very helpful.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      devqore
      wrote on last edited by
      #2

      It looks that solution in GTK is quite simple, it's sad that Qt5 hasn't nothing to offer like it was in Qt4 with QX11EmbedContainer...

      Simple example in GTK3 using python:

      import gi
      gi.require_version("Gtk", "3.0")
      from gi.repository import Gtk
      from subprocess import Popen
      
      window = Gtk.Window(title="Xterm embed")
      socket = Gtk.Socket()
      window.add(socket)
      sock_id = str(socket.get_id())
      
      # sendEvents required according to xterm documentation
      cmd = ["xterm", '-xrm', "xterm*.allowSendEvents: true", "-into", sock_id]
      
      Popen(cmd)
      socket.show()
      window.show()
      window.connect("destroy", Gtk.main_quit)
      Gtk.main()
      
      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Did you try
        https://github.com/lukas-w/qt5-x11embed

        1 Reply Last reply
        0
        • D Offline
          D Offline
          devqore
          wrote on last edited by
          #4

          @mrjj I didn't recieve any message about your response, and I saw it when I tried to find solution of this problem once again after while :P

          I already saw this repository but I didn't used because I would like to find solution without compiling additional plugins also repository looks like not developed anymore.

          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