目录存档: 用户界面

19 2012

Qt4.8.0文档翻译:QFontDatabase类参考,QFontDatabase Class Reference

- no title specified


Qt4.8.0文档翻译:QFontDatabase类参考,QFontDatabase Class Reference

成员函数文档

int QFontDatabase::addApplicationFont ( const QString & fileName ) [static]

载入名为fileName的文件中的字体,并且将它置入程序中。會返回一個编号(ID),该编号可用于:稍后使removeApplicationFont()用来删除該字体;获取該字体中包含的字体族列表。

如果該字体无法载入,则此函数返回-1。

当前只支持TrueType 字体、TrueType 字体集和OpenType 字体。

注意:目前,在Unix/X11 平台上添加程序字体需要有 fontconfig 才行。

注意:在Symbian中,字体族的名字會被裁剪到20 個字符。

此函数是从Qt 4.2 开始引入的。

参考addApplicationFontFromData()applicationFontFamilies()removeApplicationFont()。

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/02/qt4-8-0%e6%96%87%e6%a1%a3%e7%bf%bb%e8%af%91%ef%bc%9aqfontdatabase%e7%b1%bb%e5%8f%82%e8%80%83qfontdatabase-class-reference/

17 2012

Qt4.8.0文档翻译:QWidget类参考,QWidget Class Reference

- no title specified


Qt4.8.0文档翻译:QWidget类参考,QWidget Class Reference

属性文档

enabled : bool

这個属性控制的是此部件的启用状态。

一個处于启用状态的部件會处理键盘和鼠标事件;处于禁用状态的部件不會处理。

某些部件在处于禁用状态时會改变自己的外观。比如说,一個按钮可能會将它的标签变成灰色的。如果妳需要在部件的启用状态发生改变时得知这個改变信息,那么妳可以使用changeEvent()函数,并且处理QEvent::EnabledChange类型的事件。

禁用一個部件时會隐式都禁用它的所有子代部件。同样地,启用某個部件时,也會启用它的全部子代部件,除非某些子代部件曾被显式禁用过。

默认值是真(true)。

访问函数:

bool

isEnabled () const

void

setEnabled ( bool )

参考isEnabledTo()、QKeyEventQMouseEventchangeEvent()。

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/02/qt4-8-0%e6%96%87%e6%a1%a3%e7%bf%bb%e8%af%91%ef%bc%9aqwidget%e7%b1%bb%e5%8f%82%e8%80%83qwidget-class-reference/

05 2012

Qt4.7文档翻译:VideoWidget类参考,VideoWidget Class Reference

- no title specified


Qt4.7文档翻译:VideoWidget类参考,VideoWidget Class Reference

(Phonon::VideoWidget)

成员函数文档

QImage VideoWidget::snapshot () const

返回此部件中显示的当前幀的截图。

这個函数是从Qt 4.7 开始提供的。

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/01/qt4-7%e6%96%87%e6%a1%a3%e7%bf%bb%e8%af%91%ef%bc%9avideowidget%e7%b1%bb%e5%8f%82%e8%80%83videowidget-class-reference/

十二 29 2011

转载:qt翻译—QPalette Class Reference(qt调色板)

- no title specified


转载:qt翻译—QPalette Class Reference(qt调色板)

QPalette::Light这個角色指的是调色板中比按钮颜色更亮的颜色。

http://www.diybl.com/course/3_program/c/c_js/20100710/397119.html

QPalette::Light 2 比button颜色更亮.
QPalette::Midlight 3 在button和light之间.
QPalette::Dark 4 比button更暗.
QPalette::Mid 5 在button和dark之间.

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/%e8%bd%ac%e8%bd%bd%ef%bc%9aqt%e7%bf%bb%e8%af%91-qpalette-class-referenceqt%e8%b0%83%e8%89%b2%e6%9d%bf/

十二 28 2011

QColor中的pad

- no title specified


QColor中的pad

在Qt4.7.4中,QDataStream对一個QColor进行序列化时,會输出6個东西:spec、alpha、red、green、blue、pad。本座今天读到文档中的这一段时,很不理解pad是個什么东西。在问过境外论坛的人,并且读过QColor的代码之后,终于知道咯,pad在代码里只是用来占用内存位置的,当妳使用RGB模式来表示颜色时,pad无意义。

QColor同时支持RGB、HSV、CMYK、HSL四种颜色规范,以这四种规范来表示颜色所需要的数据大小是不同的。而无论是采用哪种规范,在QColor内部都是把数据存储在一個联合体里的。QColor内部对颜色数据的定义是union ct,具体是这样的:

union {

struct {

ushort alpha;

ushort red;

ushort green;

ushort blue;

ushort pad;

} argb;

struct {

ushort alpha;

ushort hue;

ushort saturation;

ushort value;

ushort pad;

} ahsv;

struct {

ushort alpha;

ushort cyan;

ushort magenta;

ushort yellow;

ushort black;

} acmyk;

struct {

ushort alpha;

ushort hue;

ushort saturation;

ushort lightness;

ushort pad;

} ahsl;

ushort array[5];

} ct;

可以看到,CMYK模式实际上要多占用一個ushort的长度。由于这几個对应于不同规范的结构体是共存于一個联合体里的,为咯让它们长度相等,就把另外三個结构体的末尾都填充上一個ushort,这块填充内存就叫做pad。

从这個代码也可以看到,QDataStream在序列化的时候既输出alpha、red、green、blue,也输出pad是必要的。因为在这個时候输出的其实是整个结构体,是不能把它们分开当作“透明”“红”“绿”“蓝”“填充”来看的。这個结构体究竟解释成什么,取决于前面输出的spec。

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/qcolor%e4%b8%ad%e7%9a%84pad/

十二 27 2011

转载:QT4工作笔记之QLabel Qmovie绘图

- no title specified


转载:QT4工作笔记之QLabel Qmovie绘图

当妳在一個QLabel中显示的图片既可能是静态图片也可能是动画图片时,直接使用QMovie就行咯。

http://blog.chinaunix.net/space.php?uid=26388681&do=blog&id=3027521

亮点:

我之所以使用QMovie而不是用QPixmap(其实也是可以的)主要是我想把绘制静态图片和动画都封装在统一的一个接口中,而用QPixmap绘制的动画是不动的。

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/%e8%bd%ac%e8%bd%bd%ef%bc%9aqt4%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0%e4%b9%8bqlabel-qmovie%e7%bb%98%e5%9b%be/

十二 27 2011

转载:QT练习5:显示GIF图片

- no title specified


QT练习5:显示GIF图片

对于gif图片的显示,无论该图片是动态的,还是静态的,都可以用QMovie。

http://www.cnblogs.com/hnrainll/archive/2011/05/22/2053701.html

亮点:

#include “widget.h”

#include “ui_widget.h”

#include <QLabel>

#include <QMovie>

Widget::Widget(QWidget *parent) :

QWidget(parent),

ui(new Ui::Widget)

{

ui->setupUi(this);

QMovie *movie = new QMovie(“D:/Project/Qt/testclass/2.gif”);

ui->label->setMovie(movie);

movie->start();

}

Widget::~Widget()

{

delete ui;

}

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/qt%e7%bb%83%e4%b9%a05%e6%98%be%e7%a4%bagif%e5%9b%be%e7%89%87/

十二 21 2011

QTableWidget清除表格内容

- no title specified


QTableWidget清除表格内容

如果只想清除表格中各个单元格的内容的话,调用QTableWidget::clearContents();如果连表头也要一起清除的话,则调用QTableWidget::clear()。

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/qtablewidget%e6%b8%85%e9%99%a4%e8%a1%a8%e6%a0%bc%e5%86%85%e5%ae%b9/

十二 12 2011

转载:QT绘图系统(The Paint System)

- no title specified


转载:QT绘图系统(The Paint System)

Qt使用的后端绘图引擎是使用命令行参数“-graphicssystem”来指定的。

http://blog.csdn.net/colorant/article/details/5365721

亮点:

可以使用 -graphicssystem raster/opengl 来指定不同的后端绘图引擎

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/%e8%bd%ac%e8%bd%bd%ef%bc%9aqt%e7%bb%98%e5%9b%be%e7%b3%bb%e7%bb%9fthe-paint-system/

十二 11 2011

转载:QtWidget 实现不规则窗体与按钮

- no title specified


转载:QtWidget 实现不规则窗体与按钮

实现不规则按钮时,可使用QWidget::setMask(const QRegion &)函数。

http://mobile.51cto.com/symbian-270171.htm

亮点:

QWidget有很多成员函数,但是它们中的一些有少量的直接功能:例如,QWidget有一个字体属性,但是它自己从来不用。有很多继承它的子类提供了实际的功能,比如QPushButton、QListBox和QTabDialog等等。

关键是使用

void QWidget::setMask ( const QBitmap & bitmap ) void QWidget::setMask ( const QRegion & region ) void QWidget::setMask ( const QRegion & region ) Causes only the parts of the widget which overlap region to be visible.

只有widget与region重叠的地方才会显示出来. 自己构造一个QRegion就行了.

void ShapedClock::resizeEvent(QResizeEvent * /* event */) { int side = qMin(width(), height()); QRegion maskedRegion(width() / 2 – side / 2, height() / 2 – side / 2, side, side, QRegion::Ellipse); setMask(maskedRegion); }

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2011/12/%e8%bd%ac%e8%bd%bd%ef%bc%9aqtwidget-%e5%ae%9e%e7%8e%b0%e4%b8%8d%e8%a7%84%e5%88%99%e7%aa%97%e4%bd%93%e4%b8%8e%e6%8c%89%e9%92%ae/

旧文章 «