Пример #1
0
    public static int Main(string[] args)
    {
        Q_INIT_RESOURCE("simpletreemodel");

        new QApplication(args);

        QFile file = new QFile(":/default.txt");

        file.Open((int)QIODevice.OpenModeFlag.ReadOnly);
        TreeModel model = new TreeModel(file.ReadAll().ConstData());

        file.Close();

        QTreeView view = new QTreeView();

        view.SetModel(model);
        view.WindowTitle = "Simple Tree Model";
        view.Show();
        return(QApplication.Exec());
    }
Пример #2
0
        public unsafe static void Main()
        {
            // Create a new QApplication object
            //QApp = QApp.CreateQApp();

            var argc = 0;

            new QApplication(ref argc, null);

            // QtUiTools is a smaller runtime, but requires manual compilation of the dll on the end users machine
            // Dim loader As New QtUiTools.QUiLoader()
            var loader = new QtDesigner.QFormBuilder();

            // Load the widget from a ui file
            var file1 = new QFile("testform1.ui");

            file1.Open(QIODevice.OpenModeFlag.ReadOnly);
            // error shows up in QtCore.OnEvent
            var widg1 = loader.Load(file1);

            file1.Close();

            widg1.ObjectName = "Simple example";
            widg1.Show();

            // TODO missing QObject.findChild QBoject.findChildren
            // This might be because the function calls in C++ use templates (generics) to specify the type
            //QWidget.QtQFindChildHelper(widg1, "pushButton", )

            // Looks like we'll need to re-implement our own findchild / find children method
            // using QWidget.Qt_qFindChild_helper
            // see C:\Qt\Qt5.7.0\5.7\Src\qtbase\src\corelib\kernel\qobject.h
            var test1 = findChild <QPushButton>(widg1, "pushbutton");

            //var test2 = getChildren(widg1);


            // Run the QApplication Process
            QApplication.Exec();
        }