void GetDemoWidgetsList(QTreeWidget treeWidget) { var assembly = typeof(Program).GetTypeInfo().Assembly; var demos = assembly.DefinedTypes.Where(x => x.GetTypeInfo().IsSubclassOf(typeof(QWidget)) && !x.GetTypeInfo().IsAbstract).ToList(); demos.Remove(this.GetType().GetTypeInfo()); foreach (TypeInfo item in demos) { var itemDescription = item.GetField("Description", BindingFlags.Public | BindingFlags.Static); //var demoObj = Activator.CreateInstance( item ); string description = null; //using (var demoObj = (QWidget) Activator.CreateInstance( item )) { if (itemDescription != null) { description = itemDescription.GetValue(null).ToString(); } //} treeWidget.AddTopLevelItem(CreateItem(item.Name, description ?? item.FullName)); demoDictionary.Add(item.Name, item); } foreach (TypeInfo item in demos.Take(1)) { // var bla = item as QWidget; //var obj = Activator.CreateInstance( item ); //obj.GetType().GetProperties(); //var widget = obj as QWidget; //widget.Show(); } }
public override void InitUI() { var strings = new QtCore.QStringList("simple, string"); tree = new QTreeWidget(this); tree.ColumnCount = 2; var column = tree.ColumnAt(0); var topLevelItem = CreateItem("hello", "this is hello"); tree.AddTopLevelItem(topLevelItem); QTreeWidgetItem helloItem = new QTreeWidgetItem(strings); tree.AddTopLevelItem(helloItem); var child = CreateItem("child", "this is child"); helloItem.AddChild(child); tree.ItemSelectionChanged += Tree_ItemSelectionChanged; this._previousSelectedItem = topLevelItem; }