Introduction

There are a number of Qt bindings available:

Qt3

A QtC based binding by Theo

Another QtC based binding by Andreas

The first one aims on linux/unix users while the second one is for win32.

Qt/Embedded

The FPC arm port and this Qt/E binding allow graphical programming on devices such as the Zaurus

Qt4

More recently a small Qt4 Binding is available. It does not depend on the obsolete QtC library. The Qt4 binding page will provide more information on how the binding works and how to use it.

How it works

FPC still can't use C++ classes natively so these interface units use the same scheme as e.g. the official C interface to Qt does: there are wrapper procedures written which export an procedural interface. This procedural interface is wrapped by an object pascal interface again to make usage easier.

This might sound like an huge overhead but these wrapper are mainly necessary to hide name mangling differences so there shouldn't be a noticable speed decrease in real world applications.

Example

This piece of code is taken from the second package mentioned above.

 var
app
: QApplicationH;
btn
: QPushButtonH;
begin
// create static ( interfaced handled ) QApplicationH
app
:= NewQApplicationH(ArgCount, ArgValues).get;
// due to a bug in fpc 1.9.5 the WideString helper methods with default parameter are disabled
//btn := NewQPushButtonH('Quit', nil).get;
btn
:= NewQPushButtonH(qs('Quit').get, nil, nil).get;
btn
.setGeometry(100, 100, 300, 300);
btn
.show;
// override the virtual eventFilter method of btn
btn
.OverrideHook.eventFilter := @TTest.MyEventFilter;
// and install the btn as it's own eventFilter
btn
.installEventFilter(btn);
// connect Qt signal to Qt slot
QObjectH
.connect(btn, SIGNAL('clicked()'), app, SLOT('quit()'));
...

If you know how Qt is used in C++, you can see that there is not much difference.

FPC and Qt的更多相关文章

  1. QT内省机制、自定义Model、数据库

    本文将介绍自定义Model过程中数据库数据源的获取方法,我使用过以下三种方式获取数据库数据源: 创建 存储对应数据库所有字段的 结构体,将结构体置于容器中返回,然后根据索引值(QModelIndex) ...

  2. Ubuntu 下安装QT

    Ubuntu 下安装QT 本文使用的环境 QT Library: qt-everywhere-opensource-src-4.7.4.tar.gz QT Creator: qt-creator-li ...

  3. Qt安装配置

    Qt Creator: 下载: Qt 5.5.1 for Windows 32-bit(MinGW 4.9.2, 1.0 GB):http://download.qt.io/official_rele ...

  4. Qt信号与槽自动关联机制

    参考链接1:http://blog.csdn.net/skyhawk452/article/details/6121407 参考链接2:http://blog.csdn.net/memory_exce ...

  5. 保持Qt GUI响应的几种方法

    最开始使用Qt时就遇到过QT Gui失去响应的问题,我是用多线程的方式解决的,然而通常来说,多线程是会降低程序的运行速度. 之后,在使用QSqlQuery::execBatch()函数时,Qt Gui ...

  6. Qt 中使用Singleton模式需小心

    在qt中,使用Singleton模式时一定要小心.因为Singleton模式中使用的是静态对象,静态对象是直到程序结束才被释放的,然而,一旦把该静态对象纳入了Qt的父子对象体系,就会导致不明确的行为. ...

  7. Qt——组件位置随窗口变化

    当我们用Qt Designer设计界面时,有时会面临这样一个问题:需要在窗口指定位置放置组件,并且当窗口位置大小改变时,该组件相对其父对象的位置是不变的,如下面两幅图所示 ,首先看上面这幅图,注意bu ...

  8. (转) Qt 出现“undefined reference to `vtable for”原因总结

    由于Qt本身实现的机制所限,我们在使用Qt制作某些软件程序的时候,会遇到各种各样这样那样的问题,而且很多是很难,或者根本找不到原因的,即使解决了问题,如果有人问你为什么,你只能回答--不知道. 今天我 ...

  9. qt中ui的 使用介绍

    1.什么是ui?ui通常是用Qt 设计师设计出来的界面文件的后缀.通常情况下ui是一个指向这个界面类的指针.ui-> 一般就是用来访问这个界面类里面的控件.例如你的ui文件里有一个叫okButt ...

随机推荐

  1. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录

    0.目录 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.感谢 在此感谢.net ...

  2. swiper实例应用

    1.手机竖屏单页滑 为了防止图压缩,单独切图,背景用纯色 2.自由滑 很长的图,自由切割

  3. 使用Xcode打包上传APP

    1.打开xcode,进入product->Scheme->EditScheme,找到Archive,最上面的设备选择IOSDevice,在BuildConfiguration中选中Rele ...

  4. 性能优化:使用SparseArray代替HashMap<Integer,Object>(转)

    HashMap是java里比较常用的一个集合类,我比较习惯用来缓存一些处理后的结果.最近在做一个Android项目,在代码中定义这样一个变量,实例化时,Eclipse却给出了一个 performanc ...

  5. .net core下的dotnet全局工具

    .net core 2.1后支持了一个全新的部署和扩展命令,可以自己注册全局命令行. dotnet install tool -g dotnetsaydotnetsay 也可以自己构建自己的命令行,一 ...

  6. LPC43xx SGPIO Slice 输入输出连接表

  7. STM32 UART DMA实现未知数据长度接收

    串口通信是经常使用到的功能,在STM32中UART具有DMA功能,并且收发都可以使用DMA,使用DMA发送基本上大家不会遇到什么问题,因为发送的时候会告知DMA发送的数据长度,DMA按照发送的长度直接 ...

  8. User Agent Strings列表 — Kejun's Blog

    曾经,ME 就需要这里的东西了. http://www.useragentstring.com/pages/All/

  9. POJ 3076 SUKODU [Dangcing Links DLX精准覆盖]

    和3074仅仅有数目的不同,3074是9×9.本来想直接用3074的.然后MLE,,,就差那么20M的空间,,. 从这里学习到了解法: http://www.cnblogs.com/ylfdrib/a ...

  10. 关于curl: (2) Failed Initialization

    一開始是由于curl无法訪问https网上说,要又一次编译安装curl 我就下载.. ./configure make make install 结果出现 curl: (2) Failed Initi ...