Przeglądaj źródła

ENH: Expose ctkTreeComboBox::treeView()

utility function that return the internal QTreeView of the combobox model
Julien Finet 14 lat temu
rodzic
commit
d2c6889128

+ 6 - 0
Libs/Widgets/ctkTreeComboBox.cpp

@@ -165,3 +165,9 @@ void ctkTreeComboBox::paintEvent(QPaintEvent *p)
   //qDebug() << this->itemText(0) << this->itemText(1);
   this->QComboBox::paintEvent(p);
 }
+
+// -------------------------------------------------------------------------
+QTreeView* ctkTreeComboBox::treeView()const
+{
+  return qobject_cast<QTreeView*>(this->view());
+}

+ 6 - 0
Libs/Widgets/ctkTreeComboBox.h

@@ -29,6 +29,7 @@
 
 #include "CTKWidgetsExport.h"
 
+class QTreeView;
 /// Description:
 /// ComboBox that displays the items as a tree view.
 /// See below for a use case:
@@ -56,6 +57,11 @@ public:
   virtual bool eventFilter(QObject* object, QEvent* event);
   virtual void showPopup();
   virtual void hidePopup();
+  
+  /// ctkTreeComboBox uses a QTreeView for its model view. treeView() is a
+  /// utility function that cast QComboBox::view() into a QTreeView.
+  /// \sa view()
+  QTreeView* treeView()const;
 
 protected:
   virtual void paintEvent(QPaintEvent*);