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. 001.NFS简介

    一 简介 NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布.功能是通过网络让不同的机器.不同的操作系统能够 ...

  2. react比较入门的小demo

    什么是jsx?    JSX是JavaScript  XML 这两个单词的缩写,xml和html非常类似,简单来说可以把它理解成使用各种各样的标签,大家可以自行 百度.所以jsx就是在javascri ...

  3. linux安装project lemon测评机

    (写下备用) 机子:xubuntu 16.04 LTS 1.下载lemon github地址:https://github.com/Sojiv/Project_lemon 这里download zip ...

  4. [Java]类的生命周期(上)类的加载和连接[转]

    本文来自:曹胜欢博客专栏.转载请注明出处:http://blog.csdn.net/csh624366188 类加载器,顾名思义,类加载器(class loader)用来加载 Java 类到 Java ...

  5. CentOS 7下安装nexus 3

    安装nexus 3的几个注意事项: 1.nexus 3和nexus 2不一样,nexus 2可以搜索Maven主仓库的包,但在nexus 3不能,只能搜索缓存过的包. 2.安装时关心的点在于运行环境, ...

  6. VMware vmdk文件打开方法

    打开虚拟机设置——硬盘——映射,把虚拟机磁盘文件vmdk映射到系统中即可!

  7. Calculate CRC32 as in STM32 hardware (EWARM v.5.50 and later)

    http://supp.iar.com/Support/?note=64424&from=note+11927 BackgroundThe STM32 devices from ST Micr ...

  8. 对 Git 分支 master 和 origin/master 的一些认识

    首先要明确一点,对 Git 的操作是围绕 3 个大的步骤来展开的(其实几乎所有的 SCM 都是这样) 从 git 取数据(git clone) 改动代码 将改动传回 git(git push) 这 3 ...

  9. .NET轻量级ORM组件Dapper葵花宝典

    一.摘要 为什么取名叫<葵花宝典>? 从行走江湖的世界角度来讲您可以理解为一本"武功秘籍",站在我们IT编程的世界角度应该叫"开发宝典". 如果您在 ...

  10. C# 地磅串口编程

    C# 地磅串口编程 http://www.cnblogs.com/cancer_xu/archive/2012/09/14/WeighBridge-Com.html http://www.cnblog ...