linux下能用qt5.0,qt5.0移植
qt5.0 release版终于在2012/12/19出来了
看了下源码,模块化做得很不错,很多东西都从原来的qtbase里抽出来,变成单独模块,依赖关系变得很明确
然后就抽了点时间(到年底了,事情也蛮多的)做了下移植工作
qt5.0可能刚出来,很多移植的东西没加进去,所以如果要移植到自己的开发板上,那就要做点移植的工作了
我的编译选项
./configure -v -prefix /qt5.0 -xplatform linux-mips-g++ -confirm-license -release -shared -opensource -nomake demos -nomake examples \
-qt-sql-sqlite \
-no-openvg \
-no-eglfs
其中-xplatform linux-mips-g++就是交叉编译要找的目录
最原始的代码里是没有linux-mips-g++这个目录的
所以要自己添加
创建linux-mips-g++在qtbase/mkspecs下
然后添加文件qmake.conf
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental gdb_dwarf_index
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = mipsel-linux-gcc
QMAKE_CXX = mipsel-linux-g++
QMAKE_CFLAGS += -mips32
QMAKE_CXXFLAGS += -mips32
QMAKE_LINK = mipsel-linux-g++
QMAKE_LINK_SHLIB = mipsel-linux-g++
# modifications to linux.conf
QMAKE_AR = mipsel-linux-ar cqs
QMAKE_OBJCOPY = mipsel-linux-objcopy
QMAKE_STRIP = mipsel-linux-strip
load(qt_config)
就可以了
然后执行编译选项,然后make,make install就可以了
之后就是重点,写图形插件,就是将qt生成的图片的buffer copy到板子sdk提供的fb接口上
qt5对比qt4对于插件的改动还是蛮大的,至少目录结构改了
qt4是在plugins/gfxdrivers下
qt5则在plugins/platforms下
那么就进入plugins/platforms下
自己创建个目录,写工程文件和继承对应的插件类,进行扩展(看过很多开源代码,大部分都是这种设计模式,一来你增加功能只需要添加代码就可以,二来这种结构在运行时加载,你可以随时切换,大家设计自己的工程时不妨考虑这种设计模式)
1.创建xxx.json文件(xxx就是你自定义命名)
{
"Keys": [ "xxx"]
}
2.创建main.cpp
#include
#include "qxxxintegration.h"
QT_BEGIN_NAMESPACE
class QxxxIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.1" FILE "bcm.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
QPlatformIntegration * QxxxIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
if (system.toLower() == "xxx")
return new QxxxIntegration(paramList);
return 0;
}
QT_END_NAMESPACE
#include "main.moc"
3.qxxxintegration.h(这里和后面都用linuxfb里的例子)
#ifndef QLINUXFBINTEGRATION_H
#define QLINUXFBINTEGRATION_H
#include
QT_BEGIN_NAMESPACE
class QLinuxFbIntegrationPrivate;
class QAbstractEventDispatcher;
class QLinuxFbScreen;
class QLinuxFbIntegration : public QPlatformIntegration
{
public:
QLinuxFbIntegration(const QStringList ¶mList);
~QLinuxFbIntegration();
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
QList screens() const;
QPlatformFontDatabase *fontDatabase() const;
private:
QLinuxFbScreen *m_primaryScreen;
QPlatformFontDatabase *m_fontDb;
QAbstractEventDispatcher *m_eventDispatcher;
};
QT_END_NAMESPACE
#endif // QLINUXFBINTEGRATION_H
4.qxxxintegration.cpp
#include "qlinuxfbintegration.h"
#include "qlinuxfbscreen.h"
#include
#include
#include
#include
#include
#include
#include
QT_BEGIN_NAMESPACE
QLinuxFbIntegration::QLinuxFbIntegration(const QStringList ¶mList)
: m_fontDb(new QGenericUnixFontDatabase()),
m_eventDispatcher(createUnixEventDispatcher())
{
QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher);
m_primaryScreen = new QLinuxFbScreen;
if (m_primaryScreen->initialize(paramList))
screenAdded(m_primaryScreen);
}
QLinuxFbIntegration::~QLinuxFbIntegration()
{
delete m_primaryScreen;
}
bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
default: return QPlatformIntegration::hasCapability(cap);
}
}
QPlatformPixmap *QLinuxFbIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
{
return new QRasterPlatformPixmap(type);
}
QPlatformBackingStore *QLinuxFbIntegration::createPlatformBackingStore(QWindow *window) const
{
return new QFbBackingStore(window);
}
QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWindow *window) const
{
return new QFbWindow(window);
}
QAbstractEventDispatcher *QLinuxFbIntegration::guiThreadEventDispatcher() const
{
return m_eventDispatcher;
}
QList QLinuxFbIntegration::screens() const
{
QList list;
list.append(m_primaryScreen);
return list;
}
QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const
{
return m_fontDb;
}
QT_END_NAMESPACE
5.qxxxscreen.h(这个我针对linuxfbscreen.h删改过的)
#ifndef QLINUXFBSCREEN_H
#define QLINUXFBSCREEN_H
#include
QT_BEGIN_NAMESPACE
class QPainter;
class QFbCursor;
class QLinuxFbScreen : public QFbScreen
{
Q_OBJECT
public:
QLinuxFbScreen();
~QLinuxFbScreen();
bool initialize(const QStringList &args);
public slots:
QRegion doRedraw();
private:
QImage mFbScreenImage;
int mBytesPerLine;
QPainter *mBlitter;
};
QT_END_NAMESPACE
#endif // QLINUXFBSCREEN_H
6.qxxxscreen.cpp
#include "qlinuxfbscreen.h"
#include
#include
#include // overrides QT_OPEN
#include
#include
#include
#include
#include
#include "bcminterface.h"
QT_BEGIN_NAMESPACE
#define WIDTH_FB 1440
#define HEIGHT_FB 1080
#define BYTESPERLINE (4 * WIDTH_FB)
#define DEPTH_FB (4 * 8)
#define DPI (72)
#define ROUND_PI ((double)25.4)
QLinuxFbScreen::QLinuxFbScreen()
: mBlitter(0)
{
InitBCMInterface(WIDTH_FB, HEIGHT_FB);
}
QLinuxFbScreen::~QLinuxFbScreen()
{
delete mBlitter;
}
static uchar* pBuffer = NULL;
static int nSize = 0;
bool QLinuxFbScreen::initialize(const QStringList &args)
{
#if 1
mDepth = DEPTH_FB;//determineDepth(vinfo);
mBytesPerLine = BYTESPERLINE;//finfo.line_length;
mGeometry = QRect(0, 0, WIDTH_FB, HEIGHT_FB);//determineGeometry(vinfo, userGeometry);
mFormat = QImage::Format_ARGB32;//determineFormat(vinfo, mDepth);
//printf("[GUM], format: %d, %d, \n", mFormat, QImage::Format_ARGB32_Premultiplied, __FILE__, __FUNCTION__, __LINE__);
mPhysicalSize = QSize(qRound(WIDTH_FB * ROUND_PI / DPI), qRound(HEIGHT_FB * ROUND_PI / DPI));//determinePhysicalSize(vinfo, userMmSize, mGeometry.size());
#endif
nSize = (WIDTH_FB * HEIGHT_FB * 4);
pBuffer = (uchar*)GetBcmBuffer(&nSize);
memset(pBuffer, 0, nSize);
QFbScreen::initializeCompositor();
mFbScreenImage = QImage(pBuffer, mGeometry.width(), mGeometry.height(), mBytesPerLine, mFormat);
mCursor = new QFbCursor(this);
return true;
}
QRegion QLinuxFbScreen::doRedraw()
{
QRegion touched = QFbScreen::doRedraw();
if (touched.isEmpty())
{
return touched;
}
if (!mBlitter)
mBlitter = new QPainter(&mFbScreenImage);
QVector rects = touched.rects();
for (int i = 0; i < rects.size(); i++)
mBlitter->drawImage(rects[i], *mScreenImage, rects[i]);
return touched;
}
QT_END_NAMESPACE
主要是继承了QFbScreen,要设一下成员变量的值
其中mDepth、mGeometry、mFormat、mPhysicalSize要设一下
然后初始化QFbScreen::initializeCompositor();
mCursor = new QFbCursor(this);
将你sdk上对应fb的指针传给mFbScreenImage对象,就是pBuffer的值,不同sdk有不同的做法,这里就不详说了
最后doredraw是由qt去调,进行绘画
我这里用了test/manual/qlayout作为测试例子
执行qlayout -platform xxx
结果如下
linux下能用qt5.0,qt5.0移植相关推荐
- 在LINUX下安装 Sybase ASE 11.0.3.3
在LINUX下安装 Sybase ASE 11.0.3.3 从Sybase的站点上下载两个软件包,笔者下载了11.0.3.3版本,Sybase目前已经推出了ASE11.9.2,由 于11.9.2软件包 ...
- Linux下GUI开发:GTK+ 2.0 + anjuta + glade
Linux下GUI开发:GTK+ 2.0 + anjuta + glade 1. 大家一起用gtk编程(一个序列) http://bbs.chinaunix.net/viewthread.php?ti ...
- Linux下的Silverlight:Moonlight 1.0 Beta 1发布了
Moonlight是微软Silverlight的一个开源实现,其目标平台是Linux与Unix/X11系统.自从2007年9月开始,Moonlight就在Mono项目下进行了开发,它是由Novell发 ...
- Redhat linux下安装oracle11r2手册+截图_toto_V1.0
在Linux下安装配置Oracle 11g R2详细过程(在整个过程中是在虚拟机下模拟的,虚拟机磁盘设置成了100GB) 1.Linux环境配置准备 环境:Linux:Redhat Enterp ...
- Linux 下从头再走 GTK+-3.0 (一)
原本由于项目需求在 Linux 下学习过一段时间的 GTK+2.0 图形开发,时隔一段时间,想真正深入学习一下 GTK . 这次直接从头学习 GTK+-3.0 ,并写下博文便于日后查看,也方便新手入门 ...
- linux下怎样运行oyrhon,Linux 下从头再走 GTK+-3.0 (一)
原本由于项目需求在 Linux 下学习过一段时间的 GTK+2.0 图形开发,时隔一段时间,想真正深入学习一下 GTK . 这次直接从头学习 GTK+-3.0 ,并写下博文便于日后查看,也方便新手入门 ...
- 【zz】Linux下GUI开发:GTK+ 2.0 + anjuta + glade
http://zxt85610.blog.163.com/blog/static/9670657200845115953183/ 在Linux,可以考虑用GTK(The GIMP Toolkit)来做 ...
- linux ctg重装,Linux 下从头再走 GTK+-3.0 (五)
实践中表明,纯粹利用 gtk 函数来创建 UI 是很繁琐的事,需要编写很多代码.怎样才能快速统一的建立 UI 布局呢? 可喜的是 GTK 提供了一个 GtkBuilder 用于快速创建界面.它读取一个 ...
- Linux下USB小工具usbmanager 1.0测试版发布
最近因为需要调试一些USB设备驱动,需要频繁的在Linux下查看USB设备信息,发现Linux下USB设备管理起来非常不方便.lsusb 显示连接在系统上的USB设备信息,显示的信息比较乱,查看起来不 ...
- Linux下安装二进制版mysql-8.0.15
1.添加用户 ## 添加用户组 groupadd mysql ## 添加用户,指定用户home目录 useradd -g mysql mysql -d /data/mysql ## 解压下载的mysq ...
最新文章
- 商汤招股书详解:40名教授250+博士3593位工程师,AI收入亚洲第一,一年15亿研发工资支出...
- Oracle 11g Release 2 (11.2) for Microsoft Windows (32-Bit)安装与卸除
- centos6.4 源码安装mysql5.5
- BZOJ 1232 USACO 2008 Nov. 安慰奶牛Cheer
- 2017年3月计算机二级c语言真题,2017年3月计算机二级C语言习题及答案
- js获取jsp上下文地址
- socket.io 中文手册 socket.io 中文文档
- 初学Python之谈
- FusionChartsFree设置指南
- 微信朋友验证消息是什么来源_微信好友来源朋友验证消息
- Amazon Silk 你所不知道的在Kindle背后的大数据
- latex 中文乱码问题
- QTcpServer 服务器监听失败
- OFDMA正交频分技术
- 红米note7支持html,红米Note 7
- 读书有益——》关于雪下很大的成语
- python在日常的一些用处
- 网吧组网新趋势:双光纤接入+千兆到桌面(转)
- 酷狗服务器显示失败怎么回事,酷狗常见问题答疑
- 条形码入门指南(八):二维条形码
热门文章
- Job for virtualbox.service failed because the control process exited with error
- Lead saved query bug
- why my pricing procedure is not determined in QHD 504
- 将github pages搭建的网页添加到百度搜索资源平台
- Initial load DNL_CUST_PROD0 并找出SAP S4表和CRM表的mapping关系
- S/4HANA for Customer Management里的搜索分页处理 1
- 打开Excel显示:新建EXCEL文件格式和扩展名不匹配(原因+解决办法)
- 一个点是否在矩形内的算法_478,回溯算法解单词搜索
- c字符串截取一部分字符串_Python如何截取一段字符串?
- python3.x版本的保留字总数是多少_Python3.6.5版本的保留字总数是:()-智慧树大数据分析的python基础章节答案...