title: Qt Syntax conversion from C++ to PyQt
body: <p>I am trying to rewrite some PyQt C++ code in python.
  I have done this type of syntax conversion many times, but not with a subclass example such as this.  This C++ code is intended to allow you to add comboboxes to a QTableWidget header to act similar to Excel header filters.
  I can convert most of the logic, but I need help with the subclass syntax in python for this example.  Any help is appreciated.</p>
  
  <pre><code>MyHorizontalHeader(QWidget *parent = 0) : QHeaderView(Qt::Horizontal, parent)
  {
       connect(this, SIGNAL(sectionResized(int, int, int)), this, 
               SLOT(handleSectionResized(int)));
       connect(this, SIGNAL(sectionMoved(int, int, int)), this, 
               SLOT(handleSectionMoved(int, int, int)));
       setMovable(true);
  }
  
  void showEvent(QShowEvent *e)
  {
      for (int i=0;i&lt;count();i++) {
         if (!boxes[i]) {
            QComboBox *box = new QComboBox(this);
            boxes[i] = box;
         }
         boxes[i]-&gt;setGeometry(sectionViewportPosition(i), 0, 
                                  sectionSize(i) - 5, height());
         boxes[i]-&gt;show();
      }
      QHeaderView::showEvent(e);
   }
  
  void handleSectionResized(int i)
  {
      for (int j=visualIndex(i);j&lt;count();j++) {
          int logical = logicalIndex(j);
          boxes[logical]-&gt;setGeometry(sectionViewportPosition(logical), 0, 
                                         sectionSize(logical) - 5, height());
      }
  }
  
  void handleSectionMoved(int logical, int oldVisualIndex, int newVisualIndex)
  {
      for (int i=qMin(oldVisualIndex, newVisualIndex);i&lt;count();i++){
          int logical = logicalIndex(i);
          boxes[logical]-&gt;setGeometry(sectionViewportPosition(logical), 0, 
                                         sectionSize(logical) - 5, height());
      }
  }
  
  void scrollContentsBy(int dx, int dy)
  {
     QTableWidget::scrollContentsBy(dx, dy);
     if (dx != 0)
        horizHeader-&gt;fixComboPositions();
  }
  
  void fixComboPositions()
  {
      for (int i=0;i&lt;count();i++)
          boxes[i]-&gt;setGeometry(sectionViewportPosition(i), 0, 
                                   sectionSize(i) - 5, height());
  }
  </code></pre>
  
  <p>This example source code originally comes from <a href="http://blog.qt.io/blog/2012/09/28/qt-support-weekly-27-widgets-on-a-header/" rel="nofollow">http://blog.qt.io/blog/2012/09/28/qt-support-weekly-27-widgets-on-a-header/</a></p>
  
  <p>I hope to eventually create a custom subclass that I can promote for my QTableWidgets in "Qt Designer", whereby I can have custom QTableWidget QHeaderView with combobox filters.</p>