2016-08-01 4 views
2

QtGuiにドロップダウンリストを作成する必要があります。アイテムをクリックするオプションが必要です。Python QtGuiボタンでドロップダウンリストを作成する

私は、QtGui.QComboBox()を使用しようとしましたが、コンボボックスのように開いたアイテムは選択されたアイテムがリストの中央に表示され、ウィンドウが小さい場合はすべてのアイテムが表示されません。

私は、クラスを作成することも試み:

class Window(QtGui.QWidget): 
    def __init__(self): 
     QtGui.QWidget.__init__(self) 
     layout = QtGui.QHBoxLayout(self) 
     self.button = QtGui.QToolButton(self) 
     self.button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) 
     self.button.setMenu(QtGui.QMenu(self.button)) 
     self.textBox = QtGui.QTextBrowser(self) 
     **self.textBox.append('test')** 
     self.textBox.append(QtGui.QPushButton('sgd',clicked=self._toggle_set))#it is not working!!! 
     action = QtGui.QWidgetAction(self.button) 
     action.setDefaultWidget(self.textBox) 
     self.button.menu().addAction(action) 
     layout.addWidget(self.button) 

が、私は文字列のみアイテム、

任意の提案を追加することができますか?

ありがとうございます!

答えて

0

あなたは、コンボボックススタイルシートオーバーライドすることができます。

combo.setStyleSheet("QComboBox { combobox-popup: 0; }") 

をし、それがドロップダウンリストのような項目が表示されます。

関連する問題