Write your first UI
application with

Qt for Python



Dr. Cristián Maureira-Fredes
Software Engineer @ TQtC

@cmaureir

Qt /kjut/

Cross platform C++ framework, for UI and more.


...but what about Python?
        
#include <stdio.h>
#define o stdout
#define p fputs
int main(_){int*I=&_,_I=2113,l1=3271;_=14557;_I*=503;
_<<=3;_*='=';_I<<=0==0;_I=7*'Y'*853<<2;
p(I,o);I=&_I;p(I,o);I=&_;
_+= l1*11*11;
_I += 0xF5<<8;p(I,o);I=&_I;p(I,o);}
        
    
...to get
        
        $ ./a.out
        Hello World!
        
    

(Submitted by vsz on codegolf.stackexchange.com)

        
#include <iostream>
using namespace std;

int main() {

    cout << "Hello SF Python Group!";
    return 0;
}
        
    
        
template <bool C, typename TR, typename FR>
class if_;
template <typename TR, typename FR>
struct if_<true, TR, FR>{ typedef TR result;};
template <typename TR, typename FR>
struct if_<false, TR, FR> { typedef FR result;};
int main() {
  typename if_<true, int, void*>::result n(3);
  typename if_<false, int, void*>::result p(&n);
  typedef typename if_<(sizeof(void *) > sizeof(uint32_t)),
    uint64_t, uint32_t>::result i_ptr_t;
  i_ptr_t c_p = reinterpret_cast<i_ptr_t>(p);
}
        
    

Compile-time if Template Meta-Programming (wikibooks)

(╯°□°)╯︵ ┻━┻

We are officially exposing Qt to Python


The story

2008

Qt4
Development
(PySide)

2016

Back
to the
Qt Project

2015

Qt5
Port
(PySide2)

2018

Released
(Qt for Python)

How do we do it?

How does PySide2 look like?

Hello World


import sys
from PySide2.QtWidgets import QApplication, QLabel

# Qt Application
app = QApplication([])

# Qt Widget
label = QLabel("Hello World!")
label.show()

# Executing app
sys.exit(app.exec_())
    

How does Qt play with Python?

Install


    pip install PySide2
    

٩( ᐛ )و

Examples!

What's next?

Implementation

  • Smoother module interaction (NumFocus)
  • Ad-hoc meta widgets

Integration

  • Embedded systems
  • Mobile (Android/iOS)
  • Improve the QtCreator experience

but most importantly...

What do you need?

we are community driven.

Release details

  • Python 2.7, 3.5+
  • Officially released for Qt 5.12 (12.2018)
    • Commercial and Open Source (GPL2/LGPL3) licenses
    • 5.12.3 is out!

¯\_(ツ)_/¯ 2020

Q&A

Mailing list: bit.ly/pyside2

qt.io/qt-for-python
pyside.org

#qt-pyside on Freenode
(crmaurei)

@cmaureir

Support your local groups!