QTreeWidget InitTreeView(QWidget parent = null) { var tree = new QTreeWidget(parent); tree.ColumnCount = 2; tree.SetColumnWidth(0, 160); tree.SetColumnWidth(1, 200); tree.WordWrap = true; tree.Size.Width = 260; var name = new QtCore.QStringList("name"); tree.SetHeaderLabels(name); tree.HeaderItem.SetText(1, "description"); var strings = new QtCore.QStringList("simple, string"); tree.ItemSelectionChanged += Tree_ItemSelectionChanged; //var topLevelItem = CreateItem( "CheckboxDemo", "This is checkbox demo" ); //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; return(tree); }
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(); } }
/// <summary> /// Generate /// </summary> /// <returns></returns> QLayout GenerateLayout() { //var vbox = new QVBoxLayout(parentWidget); var vbox = new QVBoxLayout(); // demo list var splitter = new QSplitter(); var vbox1 = new QVBoxLayout(); // https://doc.qt.io/qt-5/qgroupbox.html#details // demo container var demoBox = new QGroupBox("demos"); demoBox.Layout = new QHBoxLayout(); this.demoWidgetContainer = demoBox; this._treeView = InitTreeView(); GetDemoWidgetsList(this._treeView); splitter.AddWidget(this._treeView); splitter.AddWidget(demoBox); vbox.AddWidget(splitter); var bottomLayout = new QHBoxLayout(); bottomLayout.AddWidget(new QPushButton("Help")); bottomLayout.AddWidget(new QPushButton("Activate")); var quitButton = new QPushButton("Quit"); quitButton.Pressed += CloseButton_Pressed; bottomLayout.AddWidget(quitButton, 0, AlignmentFlag.AlignTop); bottomLayout.AddStretch(1); bottomLayout.AddWidget(new QPushButton("OK")); vbox.AddLayout(bottomLayout, 1); return(vbox); }
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; }
public void SetupUi(QMainWindow MainWindow) { if (MainWindow.ObjectName == "") { MainWindow.ObjectName = "MainWindow"; } QSize Size = new QSize(631, 570); Size = Size.ExpandedTo(MainWindow.MinimumSizeHint()); MainWindow.Size = Size; MainWindow.MinimumSize = new QSize(600, 450); MainWindow.WindowIcon = new QIcon(":/main/resources/monosim_128.png"); MenuFileNew = new QAction(MainWindow); MenuFileNew.ObjectName = "MenuFileNew"; MenuFileNew.icon = new QIcon(":/toolbar/resources/qt/document-new.png"); MenuFileOpen = new QAction(MainWindow); MenuFileOpen.ObjectName = "MenuFileOpen"; MenuFileOpen.icon = new QIcon(":/toolbar/resources/qt/document-open.png"); MenuFileSaveFile = new QAction(MainWindow); MenuFileSaveFile.ObjectName = "MenuFileSaveFile"; MenuFileSaveFile.Enabled = false; MenuFileSaveFile.icon = new QIcon(":/toolbar/resources/qt/document-save.png"); MenuFileSaveSim = new QAction(MainWindow); MenuFileSaveSim.ObjectName = "MenuFileSaveSim"; MenuFileSaveSim.Enabled = false; MenuFileSaveSim.icon = new QIcon(":/main/resources/chip_32.png"); MenuFileClose = new QAction(MainWindow); MenuFileClose.ObjectName = "MenuFileClose"; MenuFileClose.Enabled = false; MenuFileClose.icon = new QIcon(":/toolbar/resources/qt/document-close.png"); MenuFileSettings = new QAction(MainWindow); MenuFileSettings.ObjectName = "MenuFileSettings"; MenuFileSettings.icon = new QIcon(":/toolbar/resources/qt/configure.png"); MenuFileExit = new QAction(MainWindow); MenuFileExit.ObjectName = "MenuFileExit"; MenuFileExit.icon = new QIcon(":/toolbar/resources/qt/application-exit.png"); MenuSimConnect = new QAction(MainWindow); MenuSimConnect.ObjectName = "MenuSimConnect"; MenuSimConnect.icon = new QIcon(":/toolbar/resources/qt/network-connect.png"); MenuSimPin = new QAction(MainWindow); MenuSimPin.ObjectName = "MenuSimPin"; MenuSimPin.Enabled = false; MenuSimPin.icon = new QIcon(":/toolbar/resources/qt/document-encrypt.png"); MenuSimSaveFile = new QAction(MainWindow); MenuSimSaveFile.ObjectName = "MenuSimSaveFile"; MenuSimSaveFile.Enabled = false; MenuSimSaveFile.icon = new QIcon(":/toolbar/resources/qt/document-save.png"); MenuSimSaveSim = new QAction(MainWindow); MenuSimSaveSim.ObjectName = "MenuSimSaveSim"; MenuSimSaveSim.Enabled = false; MenuSimSaveSim.icon = new QIcon(":/main/resources/chip_32.png"); MenuSimDeleteAll = new QAction(MainWindow); MenuSimDeleteAll.ObjectName = "MenuSimDeleteAll"; MenuSimDeleteAll.Enabled = false; MenuSimDeleteAll.icon = new QIcon(":/toolbar/resources/qt/edit-delete.png"); MenuSimDisconnect = new QAction(MainWindow); MenuSimDisconnect.ObjectName = "MenuSimDisconnect"; MenuSimDisconnect.Enabled = false; MenuSimDisconnect.icon = new QIcon(":/toolbar/resources/qt/network-disconnect.png"); MenuAboutInfo = new QAction(MainWindow); MenuAboutInfo.ObjectName = "MenuAboutInfo"; MenuAboutInfo.icon = new QIcon(":/toolbar/resources/qt/dialog-information.png"); centralwidget = new QWidget(MainWindow); centralwidget.ObjectName = "centralwidget"; gridLayout = new QGridLayout(centralwidget); gridLayout.ObjectName = "gridLayout"; splitter = new QSplitter(centralwidget); splitter.ObjectName = "splitter"; splitter.Orientation = Qt.Orientation.Vertical; splitter.ChildrenCollapsible = false; FrameFile = new QGroupBox(splitter); FrameFile.ObjectName = "FrameFile"; FrameFile.MinimumSize = new QSize(0, 100); gridLayout1 = new QGridLayout(FrameFile); gridLayout1.ObjectName = "gridLayout1"; LstFileContacts = new QTreeWidget(FrameFile); LstFileContacts.ObjectName = "LstFileContacts"; LstFileContacts.Enabled = false; LstFileContacts.EditTriggers = Qyoto.Qyoto.GetCPPEnumValue("QAbstractItemView", "NoEditTriggers"); LstFileContacts.selectionMode = QAbstractItemView.SelectionMode.ExtendedSelection; LstFileContacts.ItemsExpandable = false; LstFileContacts.ExpandsOnDoubleClick = false; gridLayout1.AddWidget(LstFileContacts, 0, 0, 1, 1); splitter.AddWidget(FrameFile); FrameSim = new QGroupBox(splitter); FrameSim.ObjectName = "FrameSim"; FrameSim.MinimumSize = new QSize(0, 100); gridLayout2 = new QGridLayout(FrameSim); gridLayout2.ObjectName = "gridLayout2"; LstSimContacts = new QTreeWidget(FrameSim); LstSimContacts.ObjectName = "LstSimContacts"; LstSimContacts.Enabled = false; LstSimContacts.EditTriggers = Qyoto.Qyoto.GetCPPEnumValue("QAbstractItemView", "NoEditTriggers"); LstSimContacts.selectionMode = QAbstractItemView.SelectionMode.ExtendedSelection; LstSimContacts.ItemsExpandable = false; LstSimContacts.ExpandsOnDoubleClick = false; gridLayout2.AddWidget(LstSimContacts, 0, 0, 1, 1); splitter.AddWidget(FrameSim); gridLayout.AddWidget(splitter, 0, 0, 1, 1); MainWindow.SetCentralWidget(centralwidget); MainMenu = new QMenuBar(MainWindow); MainMenu.ObjectName = "MainMenu"; MainMenu.Geometry = new QRect(0, 0, 631, 24); MenuFileItem = new QMenu(MainMenu); MenuFileItem.ObjectName = "MenuFileItem"; MenuReaderItem = new QMenu(MainMenu); MenuReaderItem.ObjectName = "MenuReaderItem"; MenuAboutItem = new QMenu(MainMenu); MenuAboutItem.ObjectName = "MenuAboutItem"; MenuSimItem = new QMenu(MainMenu); MenuSimItem.ObjectName = "MenuSimItem"; MainWindow.SetMenuBar(MainMenu); StatusBar = new QStatusBar(MainWindow); StatusBar.ObjectName = "StatusBar"; MainWindow.SetStatusBar(StatusBar); TopToolBar = new QToolBar(MainWindow); TopToolBar.ObjectName = "TopToolBar"; TopToolBar.Movable = false; TopToolBar.Floatable = false; MainWindow.AddToolBar(Qt.ToolBarArea.TopToolBarArea, TopToolBar); MainMenu.AddAction(MenuFileItem.MenuAction()); MainMenu.AddAction(MenuReaderItem.MenuAction()); MainMenu.AddAction(MenuSimItem.MenuAction()); MainMenu.AddAction(MenuAboutItem.MenuAction()); MenuFileItem.AddAction(MenuFileNew); MenuFileItem.AddAction(MenuFileOpen); MenuFileItem.AddAction(MenuFileSaveFile); MenuFileItem.AddAction(MenuFileSaveSim); MenuFileItem.AddAction(MenuFileClose); MenuFileItem.AddSeparator(); MenuFileItem.AddAction(MenuFileSettings); MenuFileItem.AddSeparator(); MenuFileItem.AddAction(MenuFileExit); MenuAboutItem.AddAction(MenuAboutInfo); MenuSimItem.AddAction(MenuSimConnect); MenuSimItem.AddAction(MenuSimPin); MenuSimItem.AddSeparator(); MenuSimItem.AddAction(MenuSimSaveFile); MenuSimItem.AddAction(MenuSimSaveSim); MenuSimItem.AddAction(MenuSimDeleteAll); MenuSimItem.AddSeparator(); MenuSimItem.AddAction(MenuSimDisconnect); TopToolBar.AddAction(MenuFileNew); TopToolBar.AddAction(MenuFileOpen); TopToolBar.AddAction(MenuFileSaveFile); TopToolBar.AddAction(MenuFileSaveSim); TopToolBar.AddAction(MenuFileClose); TopToolBar.AddSeparator(); TopToolBar.AddAction(MenuFileSettings); TopToolBar.AddAction(MenuSimConnect); TopToolBar.AddAction(MenuSimPin); TopToolBar.AddAction(MenuSimSaveFile); TopToolBar.AddAction(MenuSimSaveSim); TopToolBar.AddAction(MenuSimDisconnect); TopToolBar.AddSeparator(); TopToolBar.AddAction(MenuAboutInfo); TopToolBar.AddAction(MenuFileExit); RetranslateUi(MainWindow); QMetaObject.ConnectSlotsByName(MainWindow); } // SetupUi