public void dispose() {
    if (readyForFrames) finish();

    try {
      QTSession.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public static void main(String args[]) {
    try {
      QTSession.open();
      GroupDrawing frame = new GroupDrawing("QT in Java");

      frame.pack();
      frame.show();
      frame.toFront();
    } catch (Exception e) {
      e.printStackTrace();
      QTSession.close();
    }
  }
  private void disposeSequenceGrabber() throws QTException {
    if (!sequenceGrabberInitialized) return;
    try {
      if (vc != null) vc.disposeQTObject();

      if (sg != null) {
        sg.stop();
        sg.disposeQTObject();
      }

      QTSession.close();
    } finally {
      sequenceGrabberInitialized = false;
    }
  }
    public void run() {

      try {

        QTSession.open();
        while (!isClosing()) {
          Thread.sleep(taskingDelay);
          sg.idleMore();
          sg.update(null);
        }

      } catch (InterruptedException ex) {

      } catch (Exception ex) {
        if (observer != null && !isClosing())
          observer.onError(QTCaptureStream.this, new CaptureException(ex));
      } finally {
        QTSession.close();
        setClosed();
      }
    }
 public void destroy() {
   QTSession.close();
 }