Beruflich Dokumente
Kultur Dokumente
Then from Ring you can load the DLL file using LoadLib() function then call the C function that called dlfunc() as
any Ring function.
See "Dynamic DLL" + NL
LoadLib("ringlib.dll")
dlfunc()
Output
Dynamic DLL
Message from dlfunc
When you read the documentation you will know about how to get parameters like (strings, numbers, lists and objects)
And how to return a value (any type) from you function.
From experience, when we support a C library or C++ Library
We discovered that a lot of functions share a lot of code
To save our time, and to quickly generate wrappers for C/C++ Libraries to be used in Ring
We have this code generator
https://github.com/ring-lang/ring/blob/master/extensions/codegen/parsec.ring
The code generator is just a Ring program < 1200 lines of Ring code
The generator take as input a configuration file contains the C/C++ library information
like Functions Prototype, Classes and Methods, Constants, Enum, Structures and members , etc.
Then the generator will generate
*.C File for C libraries (to be able to use the library functions)
*.CPP File for C++ libraries (to be able to use C++ classes and methods)
*.Ring File (to be able to use C++ classes as Ring classes)
*.RH file (Constants)
To understand how the generator work check this extension for the Allegro game programming library
https://github.com/ring-lang/ring/tree/master/extensions/ringallegro
At first we have the configuration file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf
To write this file, i just used the Allegro documentation + the Ring code generator rules
Then after executing the generator using this batch file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat
or using this script
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.sh
I get the generated source code file
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/ring_allegro.c
The generated source code file (ring_allegro.c) is around 12,000 Lines of code (12 KLOC)
While the configuration file is less than 1 KLOC
To build the library (create the DLL files)
https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat
Also you can check this extension for the LibSDL Library
https://github.com/ring-lang/ring/tree/master/extensions/ringsdl
After this know you should know about
1 - Writing the configuration file
2 - Using the Code Generator
3 - Building your library/extension
4 - Using your library/extension from Ring code
Let us move now to you question about Qt
We have RingQt which is just an extension to ring (ringqt.dll)
You dont need to modify Ring.
1. You just need to modify RingQt
2. Or extend Ring with another extension based on Qt (but the same Qt version)
For the first option see the RingQt extension
https://github.com/ring-lang/ring/tree/master/extensions/ringqt
Configuration file
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/qt.cf
To generate the source code
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.sh
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencodeandroid.bat
To build the DLL/so/Dylib files
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildgcc.sh
https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildclang.sh
Study RingQt
Learn about the options that you have
1. wrapping a Qt class directly
2. Creating a new class then wrapping your new class
For the second option (in the previous two points or in the two points before that)
You will create new classes in C++ code
Then you merge these classes to RingQt or provide special DLL for them (your decision)
If your work is general (will help others) just put it to RingQt.
if your work is special (to specific application) just put it in another extension.
for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("R"+X+"C"+Y)
setitem(x-1,y-1, item1)
next
next
setcentralwidget(table1)
show()
}
exec()
}
New qApp {
win1 = new qMainWindow() {
setGeometry(100,100,800,600)
setwindowtitle("Using QTableWidget")
Table1 = new qTableWidget(win1) {
setrowcount(10) setcolumncount(10)
setGeometry(10,10,400,400)
68.49. How to add Combobox and other elements to the cells of a QTableWidget? 810
Ring Documentation, Release 1.3
for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("10")
setitem(x-1,y-1,item1)
next
next
}
btn1 = new qPushButton(win1) {
setText("Increase")
setGeometry(510,10,100,30)
setClickEvent("pClick()")
}
show()
}
exec()
}
func pClick
for nRow = 0 to Table1.rowcount() - 1
for nCol = 0 to Table1.columncount() - 1
Table1.item(nRow,nCol) {
if isSelected()
setText( "" + ( 10 + text()) )
ok
}
next
next
SIXTYNINE
LANGUAGE REFERENCE
Keywords Count : 46
again
and
but
bye
call
case
catch
changeringkeyword
changeringoperator
class
def
do
done
else
elseif
end
exit
812
Ring Documentation, Release 1.3
for
from
func
get
give
if
import
in
load
loadsyntax
loop
new
next
not
off
ok
on
or
other
package
private
put
return
see
step
switch
to
try
while
closelib() copy()
cos() cosh() currentdir() date() dec() decimals() decrypt() del()
diffdays() dir() download() encrypt() eval() exefilename()
exefolder() exp()
fabs() fclose() feof() ferror() fexists() fflush() fgetc() fgetpos()
fgets() filename() find() floor() fopen() fputc() fputs() fread()
freopen() fseek() fsetpos() ftell() functions() fwrite()
getattribute() getchar()
globals() hex() hex2str() input() insert() intvalue() isalnum() isalpha()
isandroid() isattribute() iscfunction() isclass() iscntrl()
isdigit() isfreebsd() isfunction()
isglobal() isgraph() islinux() islist() islocal()
islower() ismacosx() ismethod()
ismsdos() isnull() isnumber() isobject() ispackage()
ispackageclass() isprint() isprivateattribute()
isprivatemethod() ispunct() isspace() isstring()
isunix() isupper() iswindows() iswindows64()
isxdigit() left() len() lines() list() list2str() loadlib() locals()
log() log10() lower() max() md5() mergemethods() methods() min()
murmur3hash() mysql_autocommit() mysql_close()
mysql_columns() mysql_commit() mysql_connect() mysql_error()
mysql_escape_string()
mysql_info() mysql_init() mysql_insert_id() mysql_next_result()
mysql_query() mysql_result() mysql_result2() mysql_rollback()
nullpointer() number() object2pointer() objectid()
odbc_autocommit() odbc_close() odbc_colcount() odbc_columns()
odbc_commit() odbc_connect() odbc_datasources()
odbc_disconnect() odbc_drivers() odbc_execute() odbc_fetch() odbc_getdata()
odbc_init() odbc_rollback() odbc_tables() packageclasses() packagename()
packages() perror() pointer2object() pow()
prevfilename() ptrcmp() raise() randbytes() random()
read() remove() rename()
reverse() rewind() right()
ring_state_init() ring_state_runcode() ring_state_delete()
ring_state_runfile() ring_state_findvar() ring_state_newvar()
ring_state_runobjectfile() ring_state_main()
ringvm_calllist() ringvm_cfunctionslist() ringvm_classeslist()
ringvm_fileslist() ringvm_functionslist()
ringvm_memorylist() ringvm_packageslist() sendemail()
setattribute() sha1() sha224() sha256() sha384()
sha512() sin() sinh() sort() space() sqlite_close()
sqlite_errmsg() sqlite_execute()
sqlite_init() sqlite_open() sqrt() str2hex() str2list()
strcmp() string() substr() swap()
sysget() system() tan() tanh() tempfile() tempname() time() timelist()
trim() type() ungetc() unsigned() upper() varptr() version() windowsnl()