libqt6pas is working great on Linux.
I can even get ChatGPT to write simple gui apps for free pascal using it, and some of them compile and run as is without modification.
I say "some" because each time you ask it might produce different code, which does not always compile or work.
I need a Qt6 graphical hello world in free pascal.
Requirements:
- It will use the qt6 unit
- The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
qt62.pas
- All literal strings must be explicity declared as WideString variables.
- Declared variable names must be prefixed with _
- Address of WideString variables must be used in function calls.
- Everything created must be destroyed.
- Constants must be declared before they are used before variables.
- QApplication_exec does not take an argument.
- Needs objfpc directive.
Which produces this:
program HelloWorld;
{$mode objfpc}{$H+}
uses
qt6;
var
_app : QApplicationH;
_window : QWidgetH;
_helloWorld : WideString;
begin
_helloWorld := 'Hello World!';
_app := QApplication_create(@argc, @argv);
_window := QWidget_create();
QWidget_setWindowTitle(_window, @_helloWorld);
QWidget_show(_window);
QApplication_exec();
QWidget_destroy(_window);
QApplication_destroy(_app);
end.
Which compiles and runs...
It does not understand how to do event handlers correctly, but it makes an attempt when you say things like this:
I need a Qt6 graphical hello world in free pascal.
Requirements:
- It will use the qt6 unit
- The qt6 unit is described here: https://raw.githubusercontent.com/davidbannon/libqt6pas/master/cbindings/
qt62.pas
- All literal strings must be explicity declared as WideString variables.
- A text edit will be created in the main window.
- A procedure named 'what' that prints 'how' will be created.
- When a key is pressed in the text edit the procedure 'what' will be called.
- Declared variable names must be prefixed with _
- Address of WideString variables must be used in function calls.
- Everything created must be destroyed.
- Constants must be declared before they are used before variables.
- QApplication_exec does not take an argument.
- Needs objfpc directive.
So ChatGPT can't really handle event handlers or filters correctly for libqt6pas.
Those are not hard to do in Free Pascal with libqt6pas using
QAbstractButton_hook_hook_* QObject_hook_hook_events and the like though.
"teaching" ChatGPT to do those things correctly would take some patience...
But any ways, ChatGPT can do some simple things with free pascal and libqt6pas.
Here is the funny thing though, if you make the following request, it produces code that won't work.
// @2023-01-06 14:25:27 CST [Sent]
// Show me a graphical hello world using Free Pascal and qt6.
// @2023-01-06 14:25:34 CST [Received]
// This example uses the qt6 library to create a graphical hello world program using Free Pascal.
program HelloWorld;
{$mode objfpc}{$H+}
uses
qtwidgets, qtobjects, qtgui;
var
Wnd: QWidgetH;
Btn: QPushButtonH;
begin
Wnd := QWidget_Create(nil);
try
QWidget_SetWindowTitle(Wnd, 'Hello World');
Btn := QPushButton_Create(Wnd);
try
QPushButton_SetText(Btn, 'Hello World');
QWidget_SetGeometry(Btn, 10, 10, 100, 30);
QWidget_Show(Btn);
finally
QWidget_Destroy(Btn);
end;
QApplication_Exec;
finally
QWidget_Destroy(Wnd);
end;
end.