# How to access qtcore constants in Python?

**URL:** <https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137>\
**Category:** Development\
**Created:** [August 24, 2020, 6:49am UTC](https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137 "2020-08-24T06:49:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chintha\_Siva\_Prasad](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chintha_siva_prasad/32/7766_2.png) [@Chintha\_Siva\_Prasad](https://discourse.slicer.org/u/Chintha_Siva_Prasad)\
**Post date:** [August 24, 2020, 6:49am UTC](https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137/1 "2020-08-24T06:49:40Z")

</div>

I can import qt in a slicelet and use all qtwidgets. But how can I qtcore.  
And also is there a way to PyQt5 so that I can use the qtcore from there…

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 24, 2020, 2:39pm UTC](https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137/2 "2020-08-24T14:39:46Z")

</div>

Slicer uses **PythonQt** library for Python wrapping of Qt. **PyQt** is not free to use (it has GPL/commercial license), so we have never even considered using it. **Python for Qt** is very popular, as it is provided by the Qt company, but PythonQt has many advantages - most importantly that it is intended for applications that embed Python.

Anyway, Slicer imports all Qt packages in `qt` namespace. For example, `QFile` class in `qtcore` can be accessed as `qt.QFile()`

---

<div class="post-metadata">

**Author:** ![Chintha\_Siva\_Prasad](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chintha_siva_prasad/32/7766_2.png) [@Chintha\_Siva\_Prasad](https://discourse.slicer.org/u/Chintha_Siva_Prasad)\
**Post date:** [August 24, 2020, 3:04pm UTC](https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137/3 "2020-08-24T15:04:27Z")

</div>

But how can I get the core variables like qtCore.horizontal, vertical etc… to set the orientations, behaviour etc. of various widgets.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 24, 2020, 3:07pm UTC](https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137/4 "2020-08-24T15:07:46Z")

</div>

Constants in the global C++ `Qt` namespace are in `Qt` namespace in Python. For example `qt.Qt.Horizontal`.

---

<div class="post-metadata">

**Author:** ![Chintha\_Siva\_Prasad](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chintha_siva_prasad/32/7766_2.png) [@Chintha\_Siva\_Prasad](https://discourse.slicer.org/u/Chintha_Siva_Prasad)\
**Post date:** [August 24, 2020, 3:10pm UTC](https://discourse.slicer.org/t/how-to-access-qtcore-constants-in-python/13137/5 "2020-08-24T15:10:30Z")

</div>

That worked…  
Thank You sir…
