filcuc / nimqml Goto Github PK
View Code? Open in Web Editor NEWQt Qml bindings for the Nim programming language
License: Other
Qt Qml bindings for the Nim programming language
License: Other
Supported has been added in the DOtherSide C library and dqml. Add support also in nimqml
@filcuc Hi. Is it possible to process key-events of TextField?
Specially, how to cancel append of key?
For example qml:
TextField {
id: tfExpr
x: 10
y: 24
width: 184
height: 40
text: mainWindow.exprBuff
horizontalAlignment: Text.AlignRight
Keys.onPressed: mainWindow.tfKeyPressed(event)
}
nim-handler:
proc tfKeyPressed*(self: MainWindowHandler, event: QVariant) {.slot.} =
???
I think theme can be resolved inside QML (via functions/connections).
I'll close this issue, but theme is interest: is it possible to process with QML object in Nim-side (for example get or set some property at runtime by it's name)?
In all place it's used, the nim compiler shows an error like:
contact.nim(20, 3) Error: illformed AST: proc firstName(self: Contact): string {..} =
result = self.firstName
Cant load libDOtherSide.so.0.6
from current folder.
It should be able to load it from current folder by default, or it is not supported?.
$ ls
example.nim libDOtherSide.so.0.6 main.qml
$ file libDOtherSide.so.0.6
libDOtherSide.so.0.6: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=f66fcc30a5db1e9c2fcf34b849246392b792c776, not stripped
$ nim c -r -d:nimDebugDlOpen example.nim
Hint: operation successful (7730 lines compiled; 0.034 sec total; 10.336MiB peakmem; Debug Build) [SuccessX]
Hint: /home/juan/code/example [Exec]
libDOtherSide.so.0.6: cannot open shared object file: No such file or directory
could not load: libDOtherSide.so.0.6
running the basic example with --gc:arc returns this error
/home/name/.nimble/pkgs/nimqml-0.9.0/nimqml/private/qobject.nim(159, 6) Error: cannot bind another '=destroy' to: QObject:ObjectType; previous declaration was constructed here implicitly: /home/name/.choosenim/toolchains/nim-#devel/lib/system/arc.nim(212, 15)
Hey,
using DOtherSide 0.6 and and the latest nimqml, I am able to compile all examples, but when I try to run them, they will crash with a segmentation fault. I assume it's due to the installed QT version, I'm not sure. Here is a list of all installed QT-packages on my system:
libdbusmenu-qt5-2/now 0.9.3+16.04.20200111-1ubuntu3 amd64 [installed,local]
libphonon4qt5-4/focal,now 4:4.11.1-3build1 amd64 [installed,automatic]
libphonon4qt5-data/focal,focal,now 4:4.11.1-3build1 all [installed,automatic]
libpolkit-qt5-1-1/focal,now 0.113.0-0ubuntu2 amd64 [installed,automatic]
libqscintilla2-qt5-15/focal,now 2.11.2+dfsg-6 amd64 [installed,automatic]
libqscintilla2-qt5-l10n/focal,focal,now 2.11.2+dfsg-6 all [installed,automatic]
libqt5concurrent5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5core5a/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5dbus5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5designer5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5designercomponents5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5gui5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5help5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5network5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5opengl5-dev/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5opengl5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5positioning5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5printsupport5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5qml5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5quick5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5quickcontrols2-5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed]
libqt5quickparticles5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5quickshapes5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5quicktemplates2-5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5quicktest5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5quickwidgets5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5sensors5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5sql5-sqlite/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5sql5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5svg5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5test5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5texttospeech5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5waylandclient5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5waylandcompositor5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5webchannel5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5webkit5/focal,now 5.212.0~alpha4-1ubuntu2 amd64 [installed,automatic]
libqt5widgets5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqt5x11extras5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
libqt5xml5/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
libqtermwidget5-0/focal,now 0.14.1-3ubuntu1 amd64 [installed,automatic]
obconf-qt-l10n/focal,focal,now 0.14.1-1ubuntu1 all [installed,automatic]
obconf-qt/focal,now 0.14.1-1ubuntu1 amd64 [installed,automatic]
phonon4qt5-backend-vlc/focal,now 0.11.1-1build1 amd64 [installed,automatic]
phonon4qt5/focal,now 4:4.11.1-3build1 amd64 [installed,automatic]
pinentry-qt/focal,now 1.1.0-3build1 amd64 [installed,automatic]
qdoc-qt5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qhelpgenerator-qt5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qml-module-qtgraphicaleffects/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qml-module-qtquick-controls2/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed]
qml-module-qtquick-controls/focal,now 5.12.8-0ubuntu2 amd64 [installed]
qml-module-qtquick-layouts/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qml-module-qtquick-templates2/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
qml-module-qtquick-window2/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qml-module-qtquick2/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qt5-assistant/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qt5-default/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed]
qt5-gtk-platformtheme/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
qt5-image-formats-plugins/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qt5-qmake-bin/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
qt5-qmake/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
qt5-qmltooling-plugins/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qtattributionsscanner-qt5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qtbase5-dev-tools/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
qtbase5-dev/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed,automatic]
qtchooser/focal,now 66-2build1 amd64 [installed,automatic]
qtdeclarative5-dev-tools/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
qtdeclarative5-dev/focal,now 5.12.8-0ubuntu1 amd64 [installed]
qterminal-l10n/focal,focal,now 0.14.1-0ubuntu2 all [installed,automatic]
qterminal/focal,now 0.14.1-0ubuntu2 amd64 [installed]
qtermwidget5-data/focal,focal,now 0.14.1-3ubuntu1 all [installed,automatic]
qtquickcontrols2-5-dev/focal,now 5.12.8+dfsg-0ubuntu1 amd64 [installed]
qttools5-dev-tools/focal,now 5.12.8-0ubuntu1 amd64 [installed]
qttranslations5-l10n/focal,focal,now 5.12.8-0ubuntu1 all [installed]
qtwayland5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
Are there any known incompatibilities? Am I missing something?
nimqml/src/nimqml/private/qmetaobject.nim
Line 23 in 105f5ab
parameters
is a local variable that may get deallocated, yet the code stores pointers to it that outlive its lifetime - the safer option is to use values from the seq
inside QMetaObject
since the latter is a ref
and the former don't change.
libDOtherSide is not detected even after compiling dotherside and installing nimqml via nimble!
error code:
./main
could not load: libDOtherSide.so.0.8
(compile with -d:nimDebugDlOpen for more information)
Even with the path it can't detect:
export LD_LIBRARY_PATH=/usr/local/lib/libDOtherSide.so.0.8
or
export LD_LIBRARY_PATH=/usr/local/lib/libDOtherSide.so
While I checked the libraries there are!
I noticed nim version requirement was bumped to 1.4 recently, was there a specific reason? We're using 1.2 for a number of projects for which nimqml has been really great and are not planning to migrate until later - curious what broke ;)
From my understanding, there are no cyclical references within nimqml.
Using new(typedesc, finalizer)
should also implicitly lift into =destroy
procs.
From my basic fiddling, this can be pretty easily implemented already by reordering constructor and delete procs within nimqml making use of forward declarations to prevent destructors being implicitly generated before we define them using new
in our constructors.
This has some impact on ux due to the same being required within QtObject definitions. However this is not that big of a deal since we just forward declare delete
and setup
and define them below our constructor proc.
This should make multithreading with nimqml far easier. Naturally caution must be taken when manipulating memory owned by the UI thread.
Combining CPS and the nimqml event loop however is something of interest to me that will be explored later.
I downloaded and built DOtherSide following the instructions multiple times, AFAIK without errors, but any nim program importing latest (git cloned or otherwise) nimqml crashes at runtime with message as in title.
Nim Compiler Version 1.0.4 [Linux: amd64]
Using Qt version 5.14.0
Hi. Do you have any ideas, why all nimqml application crashed on startup? Thanks.
Linux Mint 18.3 x64
Log:
Running executable
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
NimQml: QMetaObject: newQObjectMetaObject
NimQml: QMetaObject: newQAbstractItemModelMetaObject
NimQml: QMetaObject: newQAbstractListModelMetaObject
NimQml: QMetaObject: newQAbstractItemTableMetaObject
NimQml: QMetaObject: newQMetaObject
NimQml: QMetaObject: newQMetaObject
[New Thread 0x7fffeb6ba700 (LWP 6777)]
[New Thread 0x7fffdf9e7700 (LWP 6784)]
[New Thread 0x7fffdf1e6700 (LWP 6785)]
undefinedQApplication: invalid style override passed, ignoring it.
[New Thread 0x7fffde5a5700 (LWP 6786)]
[New Thread 0x7fffd73a9700 (LWP 6787)]
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QVariant: delete
NimQml: QUrl: delete
NimQml: QVariant: delete
[New Thread 0x7fffd6af7700 (LWP 6788)]
Buffer creation failed
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color): shader program is not linked
QOpenGLShaderProgram::uniformLocation(textureScale): shader program is not linked
QOpenGLShaderProgram::uniformLocation(dpr): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color): shader program is not linked
QOpenGLShaderProgram::uniformLocation(textureScale): shader program is not linked
QOpenGLShaderProgram::uniformLocation(dpr): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color): shader program is not linked
QOpenGLShaderProgram::uniformLocation(textureScale): shader program is not linked
QOpenGLShaderProgram::uniformLocation(dpr): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color): shader program is not linked
QOpenGLShaderProgram::uniformLocation(textureScale): shader program is not linked
QOpenGLShaderProgram::uniformLocation(dpr): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(color): shader program is not linked
QOpenGLShaderProgram::uniformLocation(textureScale): shader program is not linked
QOpenGLShaderProgram::uniformLocation(dpr): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
QOpenGLShaderProgram: could not create shader program
QOpenGLShader: could not create shader
QOpenGLShader: could not create shader
shader compilation failed:
""
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
QOpenGLShaderProgram::uniformLocation(opacity): shader program is not linked
NimQml: QQmlApplicationEngine: delete
[Thread 0x7fffde5a5700 (LWP 6786) exited]
[Thread 0x7fffd6af7700 (LWP 6788) exited]
NimQml: QApplication: delete
[Thread 0x7fffeb6ba700 (LWP 6777) exited]
NimQml: QQmlApplicationEngine: delete
[Thread 0x7fffd73a9700 (LWP 6787) exited]
[Thread 0x7fffdf9e7700 (LWP 6784) exited]
[Thread 0x7ffff7fceb80 (LWP 6736) exited]
[Inferior 1 (process 6736) exited normally]
OS Windows
I compiled dotherside (tried different compilers), moved the dll to binary dir (also tried C:\Windows\System32 and C:\Window\SysWOW64)
Standard nim's dynlib.loadLib
returns nil. Seems like the library is located, but it can't load.
How to fix this?
The doc should be updated with the build instructions
Following forum thread: https://forum.nim-lang.org/t/8816
There's currently no automated way to generate interface (C headers like) of a nim library to dynamically link it with nim projects.
There's also no clear separation between object files containing the LGPL code and the rest of the code.
This makes technically hard to fulfill LGPL requirements when linking with proprietary code.
@filcuc are you willing to help NimQml users to overcome these technical difficulties?
Thank you
https://github.com/filcuc/nimqml/blob/master/examples/qtobjectmacro/contact.nim#L21
This does not need to be a slot for the Q_PROPERTY to be able to access it.
Also for further questions like these, would you prefer me to just submit a pull request or open more issues?
I've a list of polygons described like
type
Point = seq[float]
Polygon = seq[Point]
Model = seq[Polygon]
let data = @[
@[
@[9.183454513549805,45.464374726885],
@[9.188776016235352,45.46058215193312],
@[9.190363883972166,45.469039846107734],
@[9.183454513549805,45.464374726885]
]
]
I'm trying to write QAbstractListModel for MapItemView to display those polygons, but the delegate requires path
to be an array of javascript objects
Map {
MapPolygon {
color: 'green'
path: [
{ latitude: -27, longitude: 153.0 },
{ latitude: -27, longitude: 154.1 },
{ latitude: -28, longitude: 153.5 }
]
}
}
I'm trying to understand how to pass a seq of coordinates from my data proc considering that each polygon may have a variable number of vertices
method data(self: MapModel, index: QModelIndex, role: int): QVariant = ...
I see that nimqml lacks QVariantList and QVariantMap but I am not aware if a workaround solution is possible.
I'm considering turning Polygon
type into a QObject
and make seq[Point]
one of its properties, but I don't know if it's possible to pass sequences from/to nimqml, that would mean declaring a list property using QQmlListProperty but it seems unavailable
Hello, I was able to run the examples and compile the libDOtherSide.dylib for Catalina and wanted to share the steps.
Install deps with homebrew:
brew install qt
brew link qt --force
brew install doxygen
Link qt paths:
sudo ln -s /usr/local/Cellar/qt/5.15.1/mkspecs /usr/local/mkspecs
sudo ln -s /usr/local/Cellar/qt/5.15.1/plugins /usr/local/plugins
Then you need to make the libDOtherSide.dylib file:
Hope this helps anyone who is also new with this sort of thing.
Note: You have to move the generated dylib to '/usr/local/lib/', and may need to rename the file if the version is appended to the name.
Hi! Thanks for this wonderful lib. I'm working with it and I find it nice to use.
I'm exploring how to link model with UI, but I'm stuck when I'm trying to create a TableView that uses Nim model with RegisterSingletonType. I'm experiencing crash on indexCallback when trying to print value via role name but I can't find where the problem is.
If I use setRootContextProperty instead of qmlRegisterSingletonType as in abstractitemmodel example it works, but I'm trying to avoiding this approach as I've read that it is going to be deprecated.
My dev environment is ubuntu 20.04 with Qt 5.12 from apt repository.
I've wrapped up a minimal test case: tablemodel.zip
please mind tablemodel.nimble
file as I use LD_LIBRARY_PATH to point to DOtherSide build path
I'll paste nim and qml code here to make it easier to understand the context:
main.nim
import NimQml
import model
proc mainProc() =
var app = newQApplication()
defer: app.delete()
let tableModel = qmlRegisterSingletonType("TableModel", 1, 0, "TableModel", proc(): TableModel = newTableModel())
var engine = newQQmlApplicationEngine()
defer: engine.delete()
engine.load(newQUrl("Main.qml"))
app.exec()
when isMainModule:
mainProc()
GC_fullcollect()
model.nim
import std/tables
import NimQml
type
RoleNames {.pure.} = enum
CustomRole = UserRole + 1,
QtObject:
type
TableModel* = ref object of QAbstractTableModel
customData*: seq[seq[int]]
proc delete(self: TableModel) =
self.QAbstractTableModel.delete
proc setup(self: TableModel) =
self.QAbstractTableModel.setup
proc newTableModel*(): TableModel =
new(result, delete)
result.customData = @[@[1,2,3],@[4,5,6],@[7,8,9]]
result.setup
method rowCount(self: TableModel, index: QModelIndex = nil): int =
return self.customData.len # rowCountCallback works
method columnCount(self: TableModel, index: QModelIndex = nil): int =
return 3 # columnCountCallback works
method data(self: TableModel, index: QModelIndex, role: int): QVariant =
assert(false) # never reached. Crash on indexCallback
method roleNames(self: TableModel): Table[int, string] =
{RoleNames.CustomRole.int: "customrole"}.toTable
Main.qml
import QtQuick 2.12
import QtQuick.Window 2.1
import TableModel 1.0
Window {
width: 640
height: 480
Component.onCompleted: visible = true
TableView {
id: table
anchors.fill: parent
columnSpacing: 1
rowSpacing: 1
clip: true
model: TableModel
delegate: Rectangle {
implicitWidth: 100
implicitHeight: 50
Text {
text: row + "," + column // works
// text: customrole // crash in indexCallback
}
MouseArea {
anchors.fill: parent
onClicked: {
console.log(row,column,index)
}
onDoubleClicked: {
console.log(customrole) // double click on cell to replicate crash
}
}
}
}
}
Debug output (after replicating crash by double clicking on TableView's cell
arkanoid@box ~/n/m/e/tablemodel> nimble exec
Executing task exec in /home/arkanoid/nim/experiments/tablemodel/tablemodel.nimble
Verifying dependencies for [email protected]
Info: Dependency on nimqml@>= 0.9.0 already satisfied
Verifying dependencies for [email protected]
Building tablemodel/main using c backend
Executing task ldrun in /home/arkanoid/nim/experiments/tablemodel/tablemodel.nimble
NimQml: QMetaObject: newQObjectMetaObject
NimQml: QMetaObject: newQAbstractItemModelMetaObject
NimQml: QMetaObject: newQAbstractListModelMetaObject
NimQml: QMetaObject: newQAbstractItemTableMetaObject
NimQml: QMetaObject: newQMetaObject
NimQml: QAbstractTableModel: setup
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: columnCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: columnCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: roleNamesCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
NimQml: QAbstractItemModel: rowCountCallback
qml: 2 2 8
qml: 2 2 8
NimQml: QAbstractItemModel: indexCallback
Traceback (most recent call last)
/home/arkanoid/nim/experiments/tablemodel/main.nim(18) main
/home/arkanoid/nim/experiments/tablemodel/main.nim(15) mainProc
/home/arkanoid/.nimble/pkgs/nimqml-0.9.0/nimqml/private/qapplication.nim(8) exec
/home/arkanoid/.nimble/pkgs/nimqml-0.9.0/nimqml/private/qabstractitemmodel.nim(106) indexCallback
/home/arkanoid/.nimble/pkgs/nimqml-0.9.0/nimqml/private/qabstractitemmodel.nim(100) index
/home/arkanoid/.nimble/pkgs/nimqml-0.9.0/nimqml/private/qabstracttablemodel.nim(51) index
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)
stack trace: (most recent call last)
/tmp/nimblecache-3325854957/nimscriptapi_1393979116.nim(187, 16)
/home/arkanoid/nim/experiments/tablemodel/tablemodel.nimble(22, 7) ldrunTask
/home/arkanoid/.choosenim/toolchains/nim-1.6.0/lib/system/nimscript.nim(273, 7) exec
/home/arkanoid/.choosenim/toolchains/nim-1.6.0/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: LD_LIBRARY_PATH=../../lib/DOtherSide/build/lib ./main [OSError]
Error: Exception raised during nimble script execution
stack trace: (most recent call last)
/tmp/nimblecache-3325854957/nimscriptapi_1393979116.nim(187, 16)
/home/arkanoid/nim/experiments/tablemodel/tablemodel.nimble(19, 7) execTask
/home/arkanoid/.choosenim/toolchains/nim-1.6.0/lib/system/nimscript.nim(273, 7) exec
/home/arkanoid/.choosenim/toolchains/nim-1.6.0/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: nimble ldrun [OSError]
Error: Exception raised during nimble script execution
Thanks
I am playing with Nim and DOtherSide on an unofficially supported Linux distribution (Void Linux) and I tried to package the library. A compiled Nim program doesn't run without the devel version of the package.
You can check the recipe here: https://github.com/voidlinux/void-packages/blob/e493813188cde0afdda5e43d87446b64ab0e2181/srcpkgs/dotherside/template
The applied patch at compilation here: https://github.com/voidlinux/void-packages/blob/e493813188cde0afdda5e43d87446b64ab0e2181/srcpkgs/dotherside/patches/fix-solib-versions.patch
And the shlibs entry: https://github.com/voidlinux/void-packages/blob/e493813188cde0afdda5e43d87446b64ab0e2181/common/shlibs#L2773
Here are the results of the builders (you can click on stdio
in the Steps and Logfiles
part of the page to see the log and the errors):
Some fixes have been tried in order to fix the failed builds but no luck at all. Have you an idea on this point?
The devel package is necessary in order to run a Nim program which uses nimqml
.
$ ./main
could not load: libDOtherSide.so
compile with -d:nimDebugDlOpen for more information
A Void package maintener, @Gottox, asked me to run ldd
and I got the following result with the hello world program:
$ ldd ./main
linux-vdso.so.1 (0x00007ffda2921000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f4bac6ee000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f4bac4e6000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f4bac2e2000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f4babf44000)
/lib/ld-linux-x86-64.so.2 (0x00007f4bac9ff000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f4babd26000)
He said to me that it is not normal and that:
the program shouldn't open the so file directly
but instead objdump -x the so-file while building and using the SONAME field instead
What do you think about this?
I am trying to understand the abstractitemmodel example.
I don't get these few lines. When I look at the QAbstractListModel subclassing documentation I am not managing to see where those delete
and setup
are explained.
Any help is welcomed. Regards.
Hi. I tried to take out window's initialization code to separated proc, but application crashed:
main.nim:
import nimqml, os, ospaths
import mainWindow
proc loadResources(app: QApplication) =
for resfile in walkFiles(joinPath(app.applicationDirPath, "*.rcc")):
QResource.registerResource(resfile)
proc loadMainWindow(app: QApplication, engine: QQmlApplicationEngine) =
let mainWindowLogic = newMainWindowLogic(app, engine)
defer: mainWindowLogic.delete
let mainWindowLogicVar = newQVariant(mainWindowLogic)
defer: mainWindowLogicVar.delete
let qurl = newQUrl("qrc:///mainWindow.qml");
defer: qurl.delete
engine.load(qurl)
engine.setRootContextProperty("mainWindow", mainWindowLogicVar)
proc mainProc() =
var app = newQApplication()
defer: app.delete()
loadResources(app)
var engine = newQQmlApplicationEngine()
defer: engine.delete()
loadMainWindow(app, engine)
app.exec()
when isMainModule:
mainProc()
GC_fullcollect()
crashes when button clicked (onClicked: mainWindow.btnClicked()
)
and this code works fine:
import nimqml, os, ospaths
import mainWindow
proc loadResources(app: QApplication) =
for resfile in walkFiles(joinPath(app.applicationDirPath, "*.rcc")):
QResource.registerResource(resfile)
proc mainProc() =
var app = newQApplication()
defer: app.delete()
loadResources(app)
var engine = newQQmlApplicationEngine()
defer: engine.delete()
let mainWindowLogic = newMainWindowLogic(app, engine)
defer: mainWindowLogic.delete
let mainWindowLogicVar = newQVariant(mainWindowLogic)
defer: mainWindowLogicVar.delete
let qurl = newQUrl("qrc:///mainWindow.qml");
defer: qurl.delete
engine.load(qurl)
engine.setRootContextProperty("mainWindow", mainWindowLogicVar)
app.exec()
when isMainModule:
mainProc()
GC_fullcollect()
What differents?
Thanks.
I installed it manually from repo, Arch Linux AUR is broken.
It cant find it on the place it installs it, then I symlinked and it works,
it seems that the make install
installs it on a place it can not find it.
$ nim c -r -d:nimDebugDlOpen example.nim
Hint: operation successful (7730 lines compiled; 0.034 sec total; 10.336MiB peakmem; Debug Build) [SuccessX]
Hint: /home/juan/code/example [Exec]
libDOtherSide.so.0.6: cannot open shared object file: No such file or directory
could not load: libDOtherSide.so.0.6
sudo ln -sv /usr/local/lib/libDOtherSide.so.0.6 /usr/lib/libDOtherSide.so.0.6
[sudo] password for juan:
'/usr/lib/libDOtherSide.so.0.6' -> '/usr/local/lib/libDOtherSide.so.0.6'
[juan@n src]$ nim c -r -d:nimDebugDlOpen example.nim
Hint: operation successful (7730 lines compiled; 0.034 sec total; 10.336MiB peakmem; Debug Build) [SuccessX]
Hint: /home/juan/code/example [Exec]
QSettings::value: Empty key passed
QSettings::value: Empty key passed
QApplication: invalid style override passed, ignoring it.
Available styles: Breeze, bb10dark, bb10bright, cleanlooks, gtk2, cde, motif, plastique, Oxygen, QtCurve, Windows, Fusion
# It Works!.
Heyho everybody.
First of all, thank you very much for making this package! I am currently working my way through a couple QML tutorials and playing around with it.
I stumbled over something though:
One of my resources I look at are a series of youtube videos from KDAB about QML. There none of the examples require having an ApplicationWindow component that is set to be visible as the outer-most component in the QML file. However, when I replicate their example, I observed that without the ApplicationWindow component, no window opens and nothing renders. Given that none of the KDAB examples make use of the ApplicationWindow component, I have become curious.
Why is the ApplicationWindow component so mandatory when using nimqml?
The documentation shows that we need defer all the time.
proc mainProc() =
var app = newQApplication()
defer: app.delete()
var engine = newQQmlApplicationEngine()
defer: engine.delete()
var qVar1 = newQVariant(10)
defer: qVar1.delete()
var qVar2 = newQVariant("Hello World")
defer: qVar2.delete()
var qVar3 = newQVariant(false)
defer: qVar3.delete()
var qVar4 = newQVariant(3.5.float)
defer: qVar4.delete()
http://filcuc.github.io/nimqml/
Destructors seem to make that superflous. Is this already implemented and the documentation outdated?
Or is it not implementated yet and are you interested in doing that?
Thanks
Following #42
Using forward declaration of finalizer (delete
) function causes bug that silently skips finalizer call with --gc:arc
Possible solutions:
I see that the code does not follow import
pattern but is just a single large module. I think it would make it easier to think about the code by converting the include
into import
+ export
and handle the dependency tree
@arkanoid87 Switching from finalizers to destructors is impossible without breaking existing code. The problem is due to destructors taking a
var T
but finalizersref T
.
I'm already doing some experiments on this
case n==0: destroy can be declared on base non-ref
type and it would be called on ref object dealloc, it is possible to call parent destroy
case n==1: finalizer is called on leaf (real) type only and seems not possible to easily call parent finalizer without additional code
type
FooObj = object of RootObj
fooValue: int
BarObj = object of FooObj
barValue: int
Foo = ref FooObj
Bar = ref BarObj
const n = 0
when n == 0:
proc `=destroy`(x: var FooObj) =
echo "Goodbye Foo " & $x.fooValue
proc `=destroy`(x: var BarObj) = # `=destroy`(x: var FooObj) would be called if this proc was not be declared
x.FooObj.`=destroy`
echo "Goodbye Bar " & $x.barValue
proc newFoo: Foo =
new(result)
result.fooValue = 99
proc newBar: Bar =
new(result)
result.fooValue = 42
result.barValue = 19
when n == 1:
proc finalize(x: Foo) =
echo "Goodbye Foo " & $x.fooValue
proc finalize(x: Bar) =
x.Foo.finalize() # Error: cannot bind another '=destroy' to: FooObj
echo "Goodbye Bar " & $x.barValue
proc newFoo: Foo =
new(result, finalize)
result.fooValue = 99
proc newBar: Bar =
new(result, finalize)
result.fooValue = 42
result.barValue = 19
proc main =
var foo = newFoo()
echo foo.fooValue
var bar = newBar()
echo bar.fooValue
echo bar.barValue
if isMainModule:
main()
GC_fullCollect()
Hey,
I tried to install everything according to your tutorial, and when I wanted to compile the tutorial (with -d:nimDebugDlOpen) I got the following error message: libDOtherSide.so.0.6: cannot open shared object file: No such file or directory
which is no surprise, because make install gave me the information:
-- Installing: /usr/local/lib/libDOtherSide.so.0.7.0
-- Installing: /usr/local/lib/libDOtherSide.so.0.7
-- Installing: /usr/local/lib/libDOtherSide.so
Could you update nimqml to use the latest version?
Hi. How to fire event QtProperty->notify after text of TextField was changed?
mainWindow.qml:
import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.3
Window {
visible: true
width: 250
height: 105
title: qsTr("Main Window")
TextField {
id: textField
x: 10
y: 12
width: 232
height: 40
text: mainWindow.messageText
}
}
mainWindow.nim:
import nimqml, windowHandler
QtObject:
type MainWindowHandler* = ref object of WindowHandler
messageText: string
proc messageTextChanged(self: MainWindowHandler, messageText: string) {.signal.}
proc setMessageText(self: MainWindowHandler, messageText: string) {.slot.} =
if self.messageText == messageText: return
self.messageText = messageText
messageTextChanged(self, messageText)
proc getMessageText(self: MainWindowHandler): string {.slot.} =
result = self.messageText
QtProperty[string] messageText:
read = getMessageText
write = setMessageText
notify = messageTextChanged
Trying to create an example for #14 using a QAbstractTableModel subclass the rowCount callback is not called. Instead using a QAbstractListModel with a custom column count works.
title
Please, add nimble tags to your project, for now it can be found via "qt" search, for example, but not via "gui"
Hi. I strange behavior of async/await operaions, when I called into nimqml-signal.
ChatServer freezes at server.nim:38
chat_server_app.zip
Here is client for test:
async_client_server.zip
(also in this client can be tested server.nim without nimqml and it works fine)
Any ideas?
Hello,
is there any way to change Qt Quick Controls style, besides using enviroment variable?
I can't find any way to pass arguments to Qt and binding for QQuickStyle::setStyle() is not available either.
Hi. I have a simple project in QML with one Char and LineSeries:
main.qml
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import QtCharts 2.2
ApplicationWindow {
width: 400
height: 300
title: "Hello World"
Component.onCompleted: visible = true
ChartView {
title: "Oscil"
id: chartView
antialiasing: true
anchors.fill: parent
LineSeries {
name: "LineSeries"
useOpenGL: true
}
}
Timer {
id: refreshTimer
interval: 1 / 60 * 1000 // 60 Hz
running: true
repeat: true
onTriggered: {
//chartView.series(0).
//dataSource.update(chartView.series(0));
}
}
}
So, can I feel this "LineSeries" directly from Nim?
I must do something like in this example of C++ code:
...
const auto arrLen = std::extent<declype(arrX)>::value;
Q_ASSERT(std::extent<declype(arrY)>::value == arrLen);
/* QXYSeries* LineSeries; <- in header and created on the heap*/
for(decltype(awrrLen) i=0;i<arrLen;++i)
LineSeries->append(arrX[i],arrY[i]);
...
In fact, I need to call method LineSeries->append(arrX[i],arrY[i]);
directly from Nim.
Is it possible?
Thanks.
Currently i hit some Qt crash with the GtkTheme when an executable load Qt through the DOtherSide.so dynamically. This never happen when the DOtherSide lib is linked by the compiler.
the problem should be investigated inside Qt. For now we disable the dynlib and require explicit linking.
ints and strings are OK, but float properties end up with wrong data in QML.
I've modified slotsandproperties
example to expose this bug
append intNumber and floatNumber (read only) properties in contact.nim
import NimQml
QtObject:
type Contact* = ref object of QObject
m_name: string
m_intNumber: int
m_floatNumber: float
proc delete*(self: Contact)
proc setup(self: Contact)
proc newContact*(): Contact =
new(result, delete)
result.m_name = "InitialName"
result.m_intNumber = 42
result.m_floatNumber = 42.12345
result.setup
proc delete*(self: Contact) =
self.QObject.delete
proc setup(self: Contact) =
self.QObject.setup
proc getName*(self: Contact): string {.slot.} =
result = self.m_name
proc nameChanged*(self: Contact, name: string) {.signal.}
proc setName*(self: Contact, name: string) {.slot.} =
if self.m_name == name:
return
self.m_name = name
self.nameChanged(name)
QtProperty[string] name:
read = getName
write = setName
notify = nameChanged
proc getIntNumber*(self: Contact): int {.slot.} =
self.m_intNumber
QtProperty[int] intNumber:
read = getIntNumber
proc getFloatNumber*(self: Contact): float {.slot.} =
self.m_floatNumber
QtProperty[float] floatNumber:
read = getFloatNumber
print values in qml
import QtQuick 2.8
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
ApplicationWindow {
width: 400
height: 300
Component.onCompleted: {
visible = true;
console.log(contact.intNumber)
console.log(contact.floatNumber)
console.log(Number.isSafeInteger(contact.floatNumber))
}
ColumnLayout {
anchors.fill: parent
Label { text: "Current name is:" + contact.name }
TextField { id: textField }
Button {
text: "Change Name"
onClicked: contact.name = textField.text
}
}
}
expected output:
qml: 42
qml: 42.12345
qml: false
current output:
qml: 42
qml: 2
qml: true
DOtherSide version: v0.8.2 [7b7c0a91b558b13a968c57b9647bfc15ed962ead]
I can push this to a new branch if requested
Hi. Is it possible to build a standalone application? I mean compile nim-application statically with qt-libs and libDOtherSide (and *.qml files)?
Hi!
I'm trying to do a simple application so I can learn Nim by doing something fun, I've encountered a strange issue in my Qml Model:
Traceback (most recent call last)
/home/davide/Programmazione/Progetti/NIM/GHReleases/src/ghreleases.nim(16) ghreleases
/home/davide/Programmazione/Progetti/NIM/GHReleases/src/ghreleases.nim(13) main
/home/davide/.nimble/pkgs/nimqml-0.9.1/nimqml/private/qapplication.nim(8) exec
/home/davide/.nimble/pkgs/nimqml-0.9.1/nimqml/private/qobject.nim(131) qobjectCallback
/home/davide/.nimble/pkgs/nimqml-0.9.1/nimqml/private/qobject.nim(116) onSlotCalled
(4) onSlotCalled
/home/davide/Programmazione/Progetti/NIM/GHReleases/src/githubapi.nim(74) setUrl
/home/davide/.nimble/pkgs/nimqml-0.9.1/nimqml/private/qabstractitemmodel.nim(215) beginResetModel
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
zsh: segmentation fault (core dumped) ./ghreleases
Basically the application crashes when I call beginResetModel()
, if I remove this function call it hangs when the urlChanged()
signal is called in setUrl()
function (implemented in githubapi.nim
).
OS and Packages versions:
I have attached the application's source code (it's very small): GHReleases.tar.gz
Am I doing something wrong?
How. This library is active and will support in future? I have notice in installation:
$nimble install nimqml
Downloading https://github.com/filcuc/nimqml using git
Warning: Package 'nimqml' has an incorrect structure. It should contain a single directory hierarchy for source files, named 'nimqml', but file 'qguiapplication.nim' is in a directory named 'private' instead. This will be an error in the future.
Hint: If 'private' contains source files for building 'nimqml', rename it to 'nimqml'. Otherwise, prevent its installation by adding `skipDirs = @["private"]` to the .nimble file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.