2013-10-27 1 views
0

나는 드롭 다운 버튼을 가지고 싶은 도구 모음 ToolBar을 가지고 있습니다.QtQuick 2.0 드롭 다운 버튼

ComboBox을 사용해 보았지만 목록 모델 항목의 길이에 따라 버튼의 크기가 조정되었습니다. 클릭 이벤트에 작업을 배치하는 방법을 모르겠습니다.

ToolBar { 
    id: toolBar 
    anchors.margins: 0 
    Layout.fillWidth: true 
    layer.enabled: true 

    RowLayout { 
    ComboBox { 
     id: databaseTypeInput 

     style: ComboBoxStyle { 
     label: ToolButton { 
      implicitWidth: 20 
      implicitHeight: 20 
      iconSource: "Image.png" 
     } // ToolButton 
     } 
    } // ComboBox 
    } 
} 

어쨌든 나는 이것이 잘못된 방법이라고 생각합니다.

QtQuck 2.0의 드롭 다운 버튼을 쉽게 만들 수있는 방법은 무엇입니까?

답변

0

레이블 속성을 ToolButton에 직접 지정합니다. Qml에는 공간을 채우지 않고 버튼을 늘일 수있는 옵션이 없습니다. 시도해보십시오. 주 QML 파일

ComboBox { 
      id: databaseTypeInput 
      width: 100; 
      style: ComboBoxStyle { 
      label: MyComponent{} 
      } 
    } // ComboBox 

MyComponent.qml 내부

import QtQuick 2.1 
import QtQuick.Controls 1.1 
import QtQuick.Layouts 1.0 
import QtQuick.Controls.Styles 1.0 

Rectangle { 
    width: 100 
    height: 62 
    RowLayout { 
     Button { 
      implicitWidth: 20 
      implicitHeight: 20 
      text: "T" 
     } 
     Text { 
      text: control.currentText 
     } 
    } 
} 
+0

그래서 QML과 버튼 (미연) 드롭 다운 할 수있는 방법은 없습니다? – user14416

+0

죄송합니다. 나는 당신의 질문을 오해 할 수도 있습니다. 현재 드롭 다운 목록을 변경할 수있는 방법이 없다고 생각하지만 ComboBox의 레이블을 변경할 수 있습니다. – Dasun