문제

Qtcolorcombo를 사용하여 색상을 유지하기 위해 Combobox를 수정했습니다.http://qt.nokia.com/products/appdev/add-on-products/catalog/4/widgets/qtcolorcombobox) 'more ...'버튼 구현 세부 사항에 대한 방법으로. C ++ 및 Linux의 PYQT에서는 잘 작동하지만 Windows의 PYQT 에서이 컨트롤을 사용하면 '기본 C ++ 객체가 파괴되었습니다'. 오류는 다음과 같이 발생합니다.

...
# in constructor:
self.activated.connect(self._emitActivatedColor)
...
def _emitActivatedColor(self, index):
    if self._colorDialogEnabled and index == self.colorCount():
        print '!!!!!!!!! QtGui.QColorDialog.getColor()'
        c = QtGui.QColorDialog.getColor() # <----- :( delegate fires 'closeEditor'
        print '!!!!!!!!! ' + c.name()

        if c.isValid():
            self._numUserColors += 1
            #at the next line currentColor() tries to access C++ layer and fails
            self.addColor(c, self.currentColor().name())

            self.setCurrentIndex(index)
...

콘솔 출력이 도움이 될 수 있습니다. 편집자에서 이벤트 ()를 우선적으로 가져 왔고 얻었습니다.

  • 마우스 부트 턴 릴리스
  • 포커스 아웃
  • 떠나다
  • 페인트
  • 입력하다
  • 떠나다
  • 집중하다
  • !!!!!!!!! qtgui.qcolordialog.getColor ()
  • 창 블록
  • 페인트
  • Windowdeactivate
  • !!!!!!!!! 'CloseEditor'화재!
  • 숨다
  • 히드토리
  • 포커스 아웃
  • DEFERREDDELETE
  • !!!!!!!!! #6e6eff

누군가가 다른 환경에 다른 행동이 왜 다른지 설명 할 수 있고, 이것을 해결하기 위해 해결 방법을 제공 할 수 있습니다. 최소한의 예는 다음과 같습니다.http://docs.google.com/doc?docid=0aa0otnvdbwrrzddxynf3nv80yam1nzhm&hl=en

도움이 되었습니까?

해결책

문제는 Qcolordialog.color ()가 모달 대화 상자를 보여주고, 그 직후에 닫히는 콤보에서 초점을 맞추고, 대표단이 그것을 파괴한다는 사실 인 것 같습니다. 따라서 이러한 문제를 해결하기위한 해결 방법은 이벤트 중단입니다.

대의원에서 :

def eventFilter(self, editor, event):
    if event.type() == QtCore.QEvent.FocusOut and hasattr(editor, 'canFocusOut'):
        if not editor.canFocusOut: return False
    return QtGui.QItemDelegate.eventFilter(self, editor, event)

편집자에서는 Factout이 금지 될 때 Flag Self.canfocusout을 소개하고 True로 설정해야합니다. Qcolordialog를 보여주는 'Highlited'신호가 요소에서 발사 될 때이 작업을 수행하고 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top