I am currently trying to develop a board computer for my good old Audi A4. So I am writing a full screen app using Python Qt and in this application I want to embed Navit (an opensource GPS navigation system Navit Homepage) into my software. On their wiki page there is an example of how to embed navit:
container = new QX11EmbedContainer(this);
QString wId = QString::number(container->winId());
setenv("NAVIT_XID", wId.toAscii(), 1);
process = new QProcess(container);
process->start("navit");
Since I am developing my project in Python my code is anologous
def initNavit( self ):
container = QtGuit.QX11EmbedContainer( self )
container.setGeometry( 100, 20, 800, 480 )
container.show()
winId = container.winId()
process = QtCore.QProcess(container)
os.environ['NAVIT_XID'] = str( winId )
process.startDetached( "navit" )
The project runs just fine and the embedding works BUT when I click on the navit app, then all mouse click events seem like they are destroyed. That is, I can still move my mouse pointer but I cannot click -> nothing. Nothing in the OS nor the application.
To elaborate it has worked at times before (maybe 5 times out of a 100 test runs - seemingly with no changes) Once I close the application with alt+f4 then my mouse works again perfectly. When I click around my application without clicking on navit it still works fine too. Running navit seperatly works without flaws as well. Furthermore, when I use my keyboard to control navit it works too (even after the clicks don't work anymore).
It is important to be able to control it via mouse, because in my car it is supposed to be controlled using a touch screen.
I am running this on Ubuntu for testing but it should mainly work with rasbian as the entire project is supposed to run on my raspberry pi 2.
So the actual question, why are my mouse clicks being ignored after running the program, how does one fix it.
Here is another example where it does not work for me.
import sys
import os
from PyQt4 import QtGui
from PyQt4 import QtCore
def main():
app = QtGui.QApplication( sys.argv )
w = QtGui.QWidget()
w.resize( 1024, 800 )
w.move( 0, 0 )
w.setWindowTitle( 'Simple Embedding Test' )
w.show()
container = QtGui.QX11EmbedContainer( w )
container.resize( 800, 600 )
container.move( 0, 0 )
container.show()
winId = container.winId()
process = QtCore.QProcess(container)
os.environ['NAVIT_XID'] = str( winId )
process.startDetached("navit")
sys.exit( app.exec_() )
if __name__ == '__main__':
main()
Thank you very much for your help