How to import from Qt:: namespase (Qt5, Python3.x)?
<p>For my application I need to set some widget parameters like alignment (<code>Qt::AlignBottom</code>) and others. But I can't import them (other PyQt5 staff imports withot any issues).</p>

<p>Using this code</p>

<pre><code>from PyQt5 import Qt

progressBar = QProgressBar(splash)
progressBar.setAlignment(Qt.AlignBottom)
</code></pre>

<p>I got following error:</p>

<pre><code>Traceback (most recent call last):
  File "run_app.py", line 50, in &lt;module&gt;
    runSemApp(sys.argv)
  File "run_app.py", line 32, in runSemApp
    progressBar.setAlignment(Qt.AlignBottom)
AttributeError: 'module' object has no attribute 'AlignBottom'
</code></pre>

<p>And using this one works:</p>

<pre><code>from PyQt5.Qt import *

progressBar = QProgressBar(splash)
progressBar.setAlignment(Qt.AlignBottom)
</code></pre>

<p>Though I have working sollution I would like to import only <code>Qt.AlignBottom</code> and not <code>*</code>. And why <code>Qt.AlignBottom</code> doesn't work with <code>from PyQt5 import Qt</code>?</p>

<p>I think the confusion here is that PyQt has a special virtual module called <code>Qt</code>, which imports <em>everything</em> into a single namespace. This is a quite useful feature, but it's a real shame that the name clash with <code>QtCore.Qt</code> wasn't avoided.</p>

<p>In the first example, the error can be "fixed" by using the somewhat weird-looking <code>Qt.Qt.AlignBottom</code>. But obviously, explicitly importing from <code>QtCore</code> is a much better solution. It's also worth noting that the <code>PyQt5</code> package is a lazy loader, so <code>import PyQt5</code> will just import an empty namespace with no access to the other modules.</p>

python qt python-3.x pyqt5