qt noob으로 하나의 단추에 여러 개의 바로 가기를 추가하는 방법을 찾고있었습니다. 여기에 대한 답이 도움이되었지만, 실제로 모든 것을 함께 모으기 위해 조금 노력해야했습니다. 그래서 나는 여기에 완전한 대답을 게시하여 희망을 갖고 나를 따라 오는 다른 놈들을 도울 것이라고 생각했습니다.
나는 이것이 PyQt로 쓰여지는 것을 사과하지만 나는 그것이 아이디어를 전달할 것이라고 믿는다. 여기
# Create and setup a "Find Next" button
find_next_btn = QtGui.QPushButton(" Find &Next")
# setupButton is a small custom method to streamline setting up many buttons. See below.
setupButton(find_next_btn, 150, "Icons/arrow_right_cr.png", 30, 20, "RTL")
find_next_btn.setToolTip("Search DOWN the tree")
find_next_btn.clicked.connect(find_next)
# find_next is the method executed when the button is pressed
# Create an action for the additional shortcuts. Alt+N is already set
# by "&" in "Find &Next"
find_next_ret_act = QtGui.QAction(self, triggered=find_next_btn.animateClick)
find_next_ret_act.setShortcut(QtGui.QKeySequence("Return"))
find_next_enter_act = QtGui.QAction(self, triggered=find_next_btn.animateClick)
find_next_enter_act.setShortcut(QtGui.QKeySequence("Enter"))
# Now add (connect) these actions to the push button
find_next_btn.addActions([find_next_ret_act, find_next_enter_act])
# A method to streamline setting up multiple buttons
def setupButton(button, btn_w, image=None, icon_w=None, icon_h=None, layout_dir=None):
button.setFixedWidth(btn_w)
if image != None:
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(image))
button.setIcon(icon)
if icon_w != None:
button.setIconSize(QtCore.QSize(icon_w, icon_h))
if layout_dir == "RTL":
find_next_btn.setLayoutDirection(QtCore.Qt.RightToLeft)
이 결과 버튼입니다 : http://i.stack.imgur.com/tb5Mh.png (멍청한 놈, 나는이 게시물에 사진을 직접 삽입 할 수 없습니다입니다.)
난이 도움이되기를 바랍니다.