Hello!

I have a question, I want to display a PDF in one tab of my QTabWidget. Is this possible?

If I try

Qt Code:
  1. import sys
  2. from PyQt4.QtCore import *
  3. from PyQt4.QtGui import *
  4. from PyQt4.QtWebKit import *
  5.  
  6. app = QApplication(sys.argv)
  7. web = QWebView()
  8. web.settings().setAttribute(QWebSettings.PluginsEnabled, True)
  9. web.show()
  10. web.load(QUrl('test.pdf')) # Change path to actual file.
  11. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

everything works as expected.

If I add a QWebView to a tab, the PDF is not displayed:

Qt Code:
  1. from PyQt4 import QtGui
  2. from PyQt4 import QtCore
  3. from PyQt4.QtWebKit import*
  4. import sys
  5.  
  6.  
  7.  
  8. def main():
  9.  
  10. app = QtGui.QApplication(sys.argv)
  11. tabs = QtGui.QTabWidget()
  12. pushButton1 = QtGui.QPushButton("QPushButton 1")
  13. pushButton2 = QtGui.QPushButton("QPushButton 2")
  14.  
  15. web = QWebView()
  16.  
  17. web.settings().setAttribute(QWebSettings.PluginsEnabled, True)
  18.  
  19. web.load(QtCore.QUrl('file:///test.pdf'))
  20.  
  21. tab1 = QtGui.QWidget()
  22. tab2 = QtGui.QWidget()
  23. tab3 = QtGui.QWidget()
  24.  
  25. vBoxlayout = QtGui.QVBoxLayout()
  26.  
  27. #vBoxlayout.addWidget(pushButton2)
  28. vBoxlayout.addWidget(web)
  29. vBoxlayout.addWidget(pushButton1)
  30.  
  31. #Resize width and height
  32. tabs.resize(250, 150)
  33.  
  34. #Move QTabWidget to x:300,y:300
  35. tabs.move(300, 300)
  36.  
  37. #Set Layout for Third Tab Page
  38. tab1.setLayout(vBoxlayout)
  39.  
  40. tabs.addTab(tab1,"Tab 1")
  41. tabs.addTab(tab2,"Tab 2")
  42. tabs.addTab(tab3,"Tab 3")
  43.  
  44. tabs.setWindowTitle('PyQt QTabWidget Add Tabs and Widgets Inside Tab')
  45. tabs.show()
  46.  
  47. sys.exit(app.exec_())
  48.  
  49.  
  50. if __name__ == '__main__':
  51. main()
To copy to clipboard, switch view to plain text mode 

Can anybody tell me what I am doing wrong?
Thanks in advance!
Stefanie