FPC and Qt
Introduction
There are a number of Qt bindings available:
Qt3
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的更多相关文章
- QT内省机制、自定义Model、数据库
本文将介绍自定义Model过程中数据库数据源的获取方法,我使用过以下三种方式获取数据库数据源: 创建 存储对应数据库所有字段的 结构体,将结构体置于容器中返回,然后根据索引值(QModelIndex) ...
- Ubuntu 下安装QT
Ubuntu 下安装QT 本文使用的环境 QT Library: qt-everywhere-opensource-src-4.7.4.tar.gz QT Creator: qt-creator-li ...
- Qt安装配置
Qt Creator: 下载: Qt 5.5.1 for Windows 32-bit(MinGW 4.9.2, 1.0 GB):http://download.qt.io/official_rele ...
- Qt信号与槽自动关联机制
参考链接1:http://blog.csdn.net/skyhawk452/article/details/6121407 参考链接2:http://blog.csdn.net/memory_exce ...
- 保持Qt GUI响应的几种方法
最开始使用Qt时就遇到过QT Gui失去响应的问题,我是用多线程的方式解决的,然而通常来说,多线程是会降低程序的运行速度. 之后,在使用QSqlQuery::execBatch()函数时,Qt Gui ...
- Qt 中使用Singleton模式需小心
在qt中,使用Singleton模式时一定要小心.因为Singleton模式中使用的是静态对象,静态对象是直到程序结束才被释放的,然而,一旦把该静态对象纳入了Qt的父子对象体系,就会导致不明确的行为. ...
- Qt——组件位置随窗口变化
当我们用Qt Designer设计界面时,有时会面临这样一个问题:需要在窗口指定位置放置组件,并且当窗口位置大小改变时,该组件相对其父对象的位置是不变的,如下面两幅图所示 ,首先看上面这幅图,注意bu ...
- (转) Qt 出现“undefined reference to `vtable for”原因总结
由于Qt本身实现的机制所限,我们在使用Qt制作某些软件程序的时候,会遇到各种各样这样那样的问题,而且很多是很难,或者根本找不到原因的,即使解决了问题,如果有人问你为什么,你只能回答--不知道. 今天我 ...
- qt中ui的 使用介绍
1.什么是ui?ui通常是用Qt 设计师设计出来的界面文件的后缀.通常情况下ui是一个指向这个界面类的指针.ui-> 一般就是用来访问这个界面类里面的控件.例如你的ui文件里有一个叫okButt ...
随机推荐
- 堆排序之Java实现
堆排序之Java实现 代码: package cn.com.zfc.lesson21.sort; /** * * @title HeapSort * @describe 堆排序 * @author 张 ...
- BZOJ.2521.[SHOI2010]最小生成树(最小割ISAP/Dinic)
题目链接 一条边不变其它边减少可以看做一条边增加其它边不变. 假设要加的边lab为(A->B,v),那么肯定是要使除这条边外,A->B的每条路径上的最小权值都\(>v\),这样在连通 ...
- HDU.5985.Lucky Coins(概率DP)
题目链接 \(Description\) 有n(n<=10)种硬币,已知每种硬币的数量和它抛一次正面朝上的概率pi.进行如下过程:每次抛一次所有硬币,将正面朝下的硬币去掉.重复该过程直到只剩一种 ...
- 【坐标离散化】AOJ0531- Paint Color
日文题……一开始被题目骗了以为真的要写文件? 题目大意&&解答戳:❀ #include<iostream> #include<cstdio> #include& ...
- LightOJ 1366 - Pair of Touching Circles (统计矩形内外切圆对)
1366 - Pair of Touching Circles PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limi ...
- vbs学习笔记2——创建桌面快捷方式
脚本 Set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolde ...
- mysqltool :dodba orzdba
http://www.cnblogs.com/beyang/p/6963306.html
- BTrace housemd TProfiler
http://blog.csdn.net/y461517142/article/details/26269529 http://calvin1978.blogcn.com/articles/btrac ...
- GUN WINDOW 工具
GNU utilities for Win32 CoreUtils for Windows 或者 完整的 package dd for windows Unix ports - WHICH, TEE ...
- 在ASP.NET MVC4中实现同页面增删改查,无弹出框02,增删改查界面设计
在上一篇"在ASP.NET MVC4中实现同页面增删改查,无弹出框01,Repository的搭建"中,已经搭建好了Repository层,本篇就剩下增删改查的界面了......今 ...