1

Here is the code.

import sys

from PyQt6.QtWidgets import QApplication
from qpageview import View

app = QApplication(sys.argv)
view = View()
view.show()
sys.exit(app.exec())

When I run it from console, I get "QWidget: Must construct a QApplication before a QWidget" error. But if I change PyQt6 to PyQt5, it works and shows the widget (qpageview is also installed and works properly). Isn't a row with QApplication enough to construct QApplication in PyQt6?

4
  • 1
    What version of qpageview are you using? Commented Jun 30 at 15:34
  • 1
    first line of the docs qpageview provides a page based document viewer widget for Qt5/PyQt5. Commented Jun 30 at 15:46
  • 2
    @AhmedAEK True, but qpageview was updated about 5 months ago (see the CHANGELOG.md on the official repo) adding support for PyQt6, although it's not clear if they still support Qt5 or they dropped it (the merged PR for that update is based on lot of commits, and I didn't check them). If they kept Qt5 support, it's possible that having both PyQt5 and 6 installed may result in some conflicts, depending on how they "guess" the available versions. Commented Jun 30 at 21:14
  • @musicamante thank you very much, updating qpageview solved the problem. Commented Jul 1 at 6:48

1 Answer 1

1

Updating qpageview to version 1.0.0 solved the problem. Since this is not the first time this issue has occurred when switching from pyqt5 to pyqt6, it can be assumed that it is often resolved by updating the modules.

Sign up to request clarification or add additional context in comments.

1 Comment

More importantly, you must ensure that third party modules are compatible with the toolkit you're using: until 5 months ago, trying to update that module wouldn't have solved anything.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.