0

When trying to build my own GUI with Navit in center, I tried now a few different ways. The only working way seems to be Qt, but I´m still having problems with using it.

The following code can start Navit and my main window, but they are both independet from each other. I´m not sure how to change the size of the self.navit window and how to change position. At last I want to delete the window frame to, but this flag is the second step.

Maybe somebody can tell what I´m doing wrong. I just want navit in my main window, just like parented with the navit window in the foreground permanent.

import sys
import os
from PyQt5 import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class embedNavit(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.process = QProcess(self)
        self.setGeometry(100,100,1024,768)
        win = QWidget() 
        winId = int(win.winId())
        sub_win = QWindow.fromWinId(winId)
        self.navit = QWidget.createWindowContainer(sub_win)
        winId = self.navit.winId()
        os.putenv('NAVIT_XID',str(winId))
        #layout = QVBoxLayout(self)
        #self.addWidget(self.navit)
        self.process.start('navit')
        #self.navit.setGeometry(0,0,1024,768)
        #self.b = QtGui.QPushButton("exit", self, clicked=self.close)
        #layout.addWidget(self.navit)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    main = embedNavit()
    main.show()
    sys.exit(app.exec_())
   

This short code shows my actual step.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
WillGIam
  • 1
  • 1
  • I don't have navit , so I cannot test, but anyway why did you comment out the lines related to the layout? Try uncommenting them. – musicamante Aug 18 '21 at 11:28
  • @musicamante thanks for your comment. I commented them because I wanted to do the layout step by step. These lines do not change something. I´m not really sure how to adress the navit window right. It seems like its not parented into the "main" window. I tried self.navit but didnt change anything. – WillGIam Aug 18 '21 at 11:37
  • Are you sure this is still supported by navit? There's an old question [here](https://stackoverflow.com/q/34831557/984421) that says they had an embedding example on their wiki. But current documentation doesn't mention it. – ekhumoro Aug 18 '21 at 13:23
  • @ekhumoro I hope so. It is still on their documentation page. But this example is written in PyQt4. I tried to modificate it fitting for PyQt5. – WillGIam Aug 18 '21 at 17:58
  • @ekhumoro If not, what about the subprocess call? Is it possible to use it for my program? To embed navit in my main window? – WillGIam Aug 20 '21 at 19:11
  • @WillGIam Are you on Linux? If so, there's an [answer here](https://stackoverflow.com/a/65851251/984421) you might find helpful. – ekhumoro Aug 21 '21 at 19:15
  • @ekhumoro Well, that's a very nice post for understanding the mechanism of the different window IDs in Qt. Thank you very much! – WillGIam Aug 22 '21 at 20:16
  • @ekhumoro But because it's not really made for my expectations I think I will have to switch to Android and use C for this project... Then I don't have to take navit either. – WillGIam Aug 22 '21 at 20:17

0 Answers0