目录存档: Qt

20 2012

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

- no title specified


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

详细描述

QNetworkProxy类提供一個网络层的代理。

QNetworkProxy提供咯为 Qt 的那些网络相关的类配置网络层代理的方法。当前支持的类包括QAbstractSocketQTcpSocketQUdpSocketQTcpServerQNetworkAccessManagerQFtp。这個代理功能被设计成尽可能透明的。这句话的意思就是说,妳以前写过的网络程序应当在使用以下代码之后自动支持网络代理咯。

QNetworkProxy proxy;

proxy.setType(QNetworkProxy::Socks5Proxy);

proxy.setHostName(“proxy.example.com”);

proxy.setPort(1080);

proxy.setUser(“username”);

proxy.setPassword(“password”);

QNetworkProxy::setApplicationProxy(proxy);

除咯为整個程序设置代理之外,还可以使用QAbstractSocket::setProxy()和QTcpServer::setProxy()来为单個的套接字设置代理。可用以下代码来为特定的套接字禁用代理:

serverSocket->setProxy(QNetworkProxy::NoProxy);

如果在connectToHost()bind()listen()中使用的地址与QHostAddress::LocalHostQHostAddress::LocalHostIPv6等价,则不會使用网络代理。

每种类型的代理支持都有相应的限制。妳应当在选择使用某种代理类型之前仔细阅读ProxyType文档。

注意:对已连接的套接字,改变(代理)不起作用。如果妳想要改变已连接的套接字的代理,则应当重新连接它。

SOCKS5

Qt 4 中对 SOCKS5 的支持是基于RFC 1928RFC 1929的。所支持的认证模式是无认证和用户名/密码认证。同时支持IPv4 和IPv6。如果启用咯QNetworkProxy::HostNameLookupCapability,则域名是通过SOCKS5 服务器解析的,否则,就是在本地解析的,再将IP 发送到服务器。在妳将SOCKS5 用于QUdpSocketQTcpServer时,有些东西需要注意:

对于QUdpSocket,对bind()的调用可能會因超时而失败。如果传递给bind()的端口号不是0,则不能确保实际使用的端口号就是妳指定的端口号。使用localPort()localAddress()来获取实际使用的地址和端口号。由于使用咯代理的UDP 经过咯两个UDP 连接,所以更有可能被丢包。

对于QTcpServer,对listen()的调用可能因为超时而失败。如果传递给listen()的端口号不是0,则不能确保实际使用的端口号就是妳指定的端口号。使用serverPort()serverAddress()来获取实际用来监听连接的地址和端口号。SOCKS5中,对于listen()的每次调用,只支持接受一個连接,并且每次调用都可能會使用一個不同的serverPort()

参考QAbstractSocketQTcpServer

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%9aqnetworkproxy%e7%b1%bb%e5%8f%82%e8%80%83%ef%bc%8cqnetworkproxy-class-reference/

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/

14 2012

转载:Qt 4.7.4 – problem with libpng

- no title specified


转载:Qt 4.7.4 – problem with libpng

QT4.7.4的Windows版本有臭虫,在操作PNG图片时會报告勒個警告:libpng warning: Interlace handling should be turned on when using png_read_image。将QT升级到4.8.0就可以解决。软件有臭虫很正常,不必惊慌。

http://www.qtcentre.org/threads/44544-Qt-4-7-4-problem-with-libpng

亮点:

Hi,

This bug was identified and will be fixed. See:

[ https://bugreports.qt.nokia.com/brow...comment-164128 ]

Leonard Lee commented on QTBUG-21408:
————————————-

This issue was fixed in QTBUG-13298 for Qt 4.8.

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/02/%e8%bd%ac%e8%bd%bd%ef%bc%9aqt-4-7-4-problem-with-libpng/

09 2012

对QT中信号槽连接了解不够,导致逻辑错误

- no title specified


对QT中信号槽连接了解不够,导致逻辑错误

牵涉到的代码:

信号:

void MoneyChanged(qint32 NewMoney); //!<钱数已经改变。

成员函数:

/*!

*@brief 卖出当前货物。

*@param Good2Sell 当前要卖出的货物。

*/

void ShangHaiYanMoJi::SellGood(Good * Good2Sell)

{

QSpinBox * CrtSellSpinBox=0; //当前商品的卖出数量旋转框。

qint32 CrtPrice=0; //当前商品的价格。

Good * CrtGood=0; //当前商品。

qint32 EarnedMoney=0; //此次赚到的钱。

qint32 CrtAvePrice=0; //当前商品的平均进价。

CrtGood=Good2Sell; //当前商品的指针。

CrtPrice=CrtGood->GetPrice(); //获取当前商品的价格。

CrtSellSpinBox=CrtGood->GetSellSpinBox(); //获取卖出数量旋转框的指针。

if (CrtSellSpinBox->value()) //真正卖出咯东西,则进行结算。

{

CrtAvePrice=CrtGood->GetAvePrice(); //获取平均进价。

EarnedMoney=CrtSellSpinBox->value()*(CrtPrice-CrtAvePrice); //计算出赚到的钱数。

Money+=CrtSellSpinBox->value()*CrtPrice; //更新钱数。

emit MoneyChanged(Money); //钱数已经改变。

if (EarnedMoney>=0) //记录利润。

{

CrtGood->AddProfit(EarnedMoney); //记录利润。

} //if

else //记录亏损。

{

CrtGood->AddLose(EarnedMoney); //记录亏损。

} //else

CrtGood->AddTradeAmount(CrtSellSpinBox->value()); //记录交易量。

CrtGood->SubAmount(CrtSellSpinBox->value()); //减少存货。出货。

// CrtSellSpinBox->setMaximum(CrtSellSpinBox->maximum()-CrtSellSpinBox->value()); //设置新的最大值,这是在当前情况下能卖的商品个数。

// CrtAmountLcd=CrtGood->GetAmountLcd(); //获取商品存货数量二极管。

// CrtAmountLcd->display(CrtSellSpinBox->maximum()); //显示存货数量。

// ComputeBuySell(); //计算能买卖的货的个数。

//取出视口的矩形,将这个矩形向下移动一段距离,距离的值为当前滚动条的值。产生一个新的矩形,这个新的矩形就是用户当前实际看到的区域。

QRect CrtRect=ui->PlayScrollArea->viewport()->rect(); //取得视口的矩形。

CrtRect.moveTop(ui->PlayScrollArea->verticalScrollBar()->value()); //移动矩形。

qDebug() << __FILE__ << __LINE__ << __func__ << tr(“Scroll area height:”) << ui->PlayScrollArea->height(); //Debug.

qDebug() << __FILE__ << __LINE__ << __func__ << tr(“Scroll area widget height:”) << ui->PlayScrollArea->widget()->height(); //Debug.

if (Good2Sell->GetFrame()) //框架存在。

{

QuePourGold(Good2Sell); //将下泼金币动画添加到队列中。

PourGoldTimer.start(); //启动向下泼金币效果的定时器。

} //if

//创建“飞行文字”的队列:

QueFlyText(Good2Sell,EarnedMoney); //将飞行文字效果添加到队列中。

FlyTextTimer.start(); //启动飞行文字效果的定时器。

if (EarnedMoney>0) //是赚咯钱,则显示庆祝视频。

{

ShowCelibVideo(Good2Sell); //显示庆祝视频。

} //if

} //if

return;

} //void ShangHaiYanMoJi::SellGood(Good * Good2Sell)

信号槽:

/*!

*@brief 刷新总资产。

*@param NewDay 新的天数。

*/

void ShangHaiYanMoJi::RefreshAsset(qint32 NewDay)

{

(void)(NewDay); //不使用勒個参数。

Good * CrtGood=0; // 当前商品。

qint32 NewAsset=0; //新的总资产数。

foreach(CrtGood,GoodList) //一个个商品地计算。

{

NewAsset+=CrtGood->GetPrice()*CrtGood->GetAmount(); //加上当前商品的资产。

} //foreach

NewAsset+=Money; //加上现金。

//在二极管中显示资产数:

if (ui->AssetLcdNumber->checkOverflow(NewAsset)) //溢出。

{

qint32 DigitCount=ceil(log10(NewAsset)); //计算出位数。

if (NewAsset==pow(10,DigitCount)) //正好是10的幂.

{

DigitCount++; //再多一位。

} //if

ui->AssetLcdNumber->setDigitCount(DigitCount); //设置位数。

ui->AssetLcdNumber->updateGeometry(); //更新几何属性。

} //if

ui->AssetLcdNumber->display(NewAsset); //显示资产数。

emit AssetChanged(NewAsset); //发射信号,资产发生变化。

return;

} //void ShangHaiYanMoJi::RefreshAsset(qint32 NewDay)

连接:

connect(this,SIGNAL(MoneyChanged(qint32)),this,SLOT(RefreshAsset(qint32))); //当钱数发生改变时,刷新总资产。

预期的行为及错误:

在界面中“卖出”一定数量的某個商品时,对其进行处理的就是void ShangHaiYanMoJi::SellGood(Good * Good2Sell)函数。在这個函数中,會从界面上对应于该商品的“卖出数量”控件( QSpinBox * CrtSellSpinBox=0; //当前商品的卖出数量旋转框。,同时用来表示该商品当前有多少存货)里获取卖出的商品的数量,计算出这些数量的商品卖得的钱数,加到系统的现金数量( qint64 Money; //!<当前拥有的钱。)中去,再从界面上对应于该商品的“卖出数量”控件里减去要“卖出”的商品数量。同时发送信号( void MoneyChanged(qint32 NewMoney); //!<钱数已经改变。)以告知系统的现金总数发生变化。

由“钱数变化”信号(void MoneyChanged(qint32 NewMoney);)引发“更新资产数量”(void ShangHaiYanMoJi::RefreshAsset(qint32 NewDay))信号槽。在这個信号槽中會遍历所有种类的商品,获取其存货数量(通过前面所说的“卖出数量”控件),计算出其价值,加起来,再加上现金数量,即为系统中当前的总资产数。然后在界面上更新资产数。

本来由程序计算出来的资产数应当与由人来手动计算出的资产数相等,但是在实际调试中却不相等。程序计算出来的资产数总會多一些,而从具体的数值上来看,好像程序把刚“卖出”的商品计算咯两次一样。

出错原因:

根据出错的现象跟踪到void ShangHaiYanMoJi::SellGood(Good * Good2Sell)函数的代码中,就知道原因咯。具体的在这里:

EarnedMoney=CrtSellSpinBox->value()*(CrtPrice-CrtAvePrice); //计算出赚到的钱数。

Money+=CrtSellSpinBox->value()*CrtPrice; //更新钱数。

emit MoneyChanged(Money); //钱数已经改变。

if (EarnedMoney>=0) //记录利润。

{

CrtGood->AddProfit(EarnedMoney); //记录利润。

} //if

else //记录亏损。

{

CrtGood->AddLose(EarnedMoney); //记录亏损。

} //else

CrtGood->AddTradeAmount(CrtSellSpinBox->value()); //记录交易量。

CrtGood->SubAmount(CrtSellSpinBox->value()); //减少存货。出货。

其中,是最后的CrtGood->SubAmount(CrtSellSpinBox->value()); //减少存货。出货。这一句来将界面上的“卖出数量”控件的值减少的,此句代码位于发射“钱数改变”信号的代码(emit MoneyChanged(Money); //钱数已经改变。)之后。当执行到发射信号的代码时,钱数已经增加,而存货数量还没有减少。由于前面进行信号槽连接时没有指定连接方式,因此使用的是默认的自动连接模式,信号与信号槽本身又处于同一线程,在这种情况下,得到的是一個直接连接,也就是说信号槽在发射信号的语句执行时立即被调用。于是“更新资产”信号槽在存货数量还没有减少时便被调用,相当于将“卖出”的那么多的数量的商品再加咯一次。

验证咯一下,将发射信号的代码放到函数最后,变成下面的代码之后就计算正常咯:

/*!

*@brief 卖出当前货物。

*@param Good2Sell 当前要卖出的货物。

*/

void ShangHaiYanMoJi::SellGood(Good * Good2Sell)

{

QSpinBox * CrtSellSpinBox=0; //当前商品的卖出数量旋转框。

qint32 CrtPrice=0; //当前商品的价格。

Good * CrtGood=0; //当前商品。

qint32 EarnedMoney=0; //此次赚到的钱。

qint32 CrtAvePrice=0; //当前商品的平均进价。

CrtGood=Good2Sell; //当前商品的指针。

CrtPrice=CrtGood->GetPrice(); //获取当前商品的价格。

CrtSellSpinBox=CrtGood->GetSellSpinBox(); //获取卖出数量旋转框的指针。

if (CrtSellSpinBox->value()) //真正卖出咯东西,则进行结算。

{

CrtAvePrice=CrtGood->GetAvePrice(); //获取平均进价。

EarnedMoney=CrtSellSpinBox->value()*(CrtPrice-CrtAvePrice); //计算出赚到的钱数。

Money+=CrtSellSpinBox->value()*CrtPrice; //更新钱数。

if (EarnedMoney>=0) //记录利润。

{

CrtGood->AddProfit(EarnedMoney); //记录利润。

} //if

else //记录亏损。

{

CrtGood->AddLose(EarnedMoney); //记录亏损。

} //else

CrtGood->AddTradeAmount(CrtSellSpinBox->value()); //记录交易量。

CrtGood->SubAmount(CrtSellSpinBox->value()); //减少存货。出货。

// CrtSellSpinBox->setMaximum(CrtSellSpinBox->maximum()-CrtSellSpinBox->value()); //设置新的最大值,这是在当前情况下能卖的商品个数。

// CrtAmountLcd=CrtGood->GetAmountLcd(); //获取商品存货数量二极管。

// CrtAmountLcd->display(CrtSellSpinBox->maximum()); //显示存货数量。

// ComputeBuySell(); //计算能买卖的货的个数。

//取出视口的矩形,将这个矩形向下移动一段距离,距离的值为当前滚动条的值。产生一个新的矩形,这个新的矩形就是用户当前实际看到的区域。

QRect CrtRect=ui->PlayScrollArea->viewport()->rect(); //取得视口的矩形。

CrtRect.moveTop(ui->PlayScrollArea->verticalScrollBar()->value()); //移动矩形。

qDebug() << __FILE__ << __LINE__ << __func__ << tr(“Scroll area height:”) << ui->PlayScrollArea->height(); //Debug.

qDebug() << __FILE__ << __LINE__ << __func__ << tr(“Scroll area widget height:”) << ui->PlayScrollArea->widget()->height(); //Debug.

if (Good2Sell->GetFrame()) //框架存在。

{

QuePourGold(Good2Sell); //将下泼金币动画添加到队列中。

PourGoldTimer.start(); //启动向下泼金币效果的定时器。

} //if

//创建“飞行文字”的队列:

QueFlyText(Good2Sell,EarnedMoney); //将飞行文字效果添加到队列中。

FlyTextTimer.start(); //启动飞行文字效果的定时器。

if (EarnedMoney>0) //是赚咯钱,则显示庆祝视频。

{

ShowCelibVideo(Good2Sell); //显示庆祝视频。

} //if

emit MoneyChanged(Money); //钱数已经改变。

} //if

return;

} //void ShangHaiYanMoJi::SellGood(Good * Good2Sell)

理论支持:QT文档中说明的信号槽连接类型:

Qt4.8:Qt命名空间,Qt Namespace

类型文档

enum Qt::ConnectionType

这個枚举量描述的是信号与信号槽之间可采用的连接的类型。尤其是用来指明某個信号是应当立即传递到信号槽中还是排队等待稍后传递。

常量

描述

Qt::AutoConnection

0

(默认)如果该信号是从一個与接收对象所处的线程不同的线程中发射的,则信号會被排队,其行为就像Qt::QueuedConnection一样。否则,该信号槽會立即被调用,其行为就像Qt::DirectConnection 一样。连接类型會在信号被发射时决定。

Qt::DirectConnection

1

当信号被发射时,信号槽會立即被调用。

Qt::QueuedConnection

2

当控件权转移到接收者的线程中的事件循环时,信号槽會被调用。信号槽是在接收者的线程中执行的。

Qt::BlockingQueuedConnection

4

与QueuedConnection 类似,但是当前线程會阻塞,直到信号槽返回为止。只有在发射者与接收者处于不同的线程时,才能使用这种连接类型。注意:如果不遵守这個规则,那么可能导致妳的程序死锁。

Qt::UniqueConnection

0×80

与AutoConnection 类似,但是只有在这個连接不會与已有的连接重复时才會建立。也就是说,如果相同的信号与信号槽已经在相同的一对对象之间连接起来,那么这次的连接将會失败。这個连接类型是从Qt 4.6 开始引入的。

Qt::AutoCompatConnection

3

如果启用咯Qt 3 支持,则这個會是默认的连接类型。与AutoConnection 类似,但是在某些情况下會导致输出警告信息。参考兼容性信号和信号槽(Compatibility Signals and Slots)以了解更多信息。

对于排队式连接,其参数必须是 Qt 的元对象系统认识的类型,因为Qt 需要复制这些参数并且将它们在后台的事件中储存。如果妳尝试使用一個排队式连接而碰到这样的错误信息的话:

QObject::connect: Cannot queue arguments of type ‘MyType’

那么就在建立连接之前调用qRegisterMetaType()来注册一下这种数据类型。

如果想在跨线程使用信号和信号槽的话,参考一下跨线程的信号和信号槽(Signals and Slots Across Threads)

参考Qt中的线程支持QObject::connect()qRegisterMetaType()

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/02/%e5%af%b9qt%e4%b8%ad%e4%bf%a1%e5%8f%b7%e6%a7%bd%e8%bf%9e%e6%8e%a5%e4%ba%86%e8%a7%a3%e4%b8%8d%e5%a4%9f%e5%af%bc%e8%87%b4%e9%80%bb%e8%be%91%e9%94%99%e8%af%af/

04 2012

转载:Qt获取组合键

- no title specified


转载:Qt获取组合键

表示键盘上的“Ctrl”键的常量是Qt::ControlModifier。

http://cool.worm.blog.163.com/blog/static/643390062009614248349/

亮点:

键盘按住Ctrl+ 鼠标左键的实现

在窗体中相应mousePressEvent事件函数在其中检测Ctrl键是否按住即可。

void Window::mousePressEvent(QMouseEvent *e)
{
//
获取鼠标在点击窗体上的坐标
QPoint pos = e->pos();
if (e->button() == LeftButton)
{
if ( QApplication::keyboardModifiers () == Qt::ControlModifier)
{
//pressed
}
}
}

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/02/%e8%bd%ac%e8%bd%bd%ef%bc%9aqt%e8%8e%b7%e5%8f%96%e7%bb%84%e5%90%88%e9%94%ae/

05 2012

转载:Capturing screenshot with Phonon::VideoWidget::snapshot()

- no title specified


转载:Capturing screenshot with Phonon::VideoWidget::snapshot()

在这漏洞满天飞的年代,遇到臭虫很正常。Phonon有臭虫,导致VideoWidget::snapshot()函数无效。替代方法是QPixmap snapshot = QPixmap::grabWindow(vwidget->winId());

http://developer.qt.nokia.com/forums/viewthread/2487

亮点:

inally I got it working by changing this line:

  1. 1.const QPixmap& snapshot = QPixmap::grabWidget(m_videoPlayer->videoWidget());

to

  1. 1.const QPixmap& snapshot = QPixmap::grabWindow(m_videoPlayer->videoWidget()->winId());

As from the documentation, the QPixmap::grabWindow() function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.

The window system identifier (WId) can be retrieved using the QWidget::winId() function. The rationale for using a window identifier and not a QWidget, is to enable grabbing of windows that are not part of the application, window system frames, and so on.

Anyway I think it is definitely a bug in Phonon, so I will submit a test report soon. Thanks again for your time! :)

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/01/%e8%bd%ac%e8%bd%bd%ef%bc%9acapturing-screenshot-with-phononvideowidgetsnapshot/

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/

04 2012

转载:phonon 视频 播放器

- no title specified


转载:phonon 视频 播放器

使用phonon来做播放器非常简单。

http://www.diybl.com/course/3_program/c++/cppjs/20091228/185844.html

亮点:

02

03

#include <QApplication>

04

#include <QWidget>

05

06

#include <Phonon/MediaObject>

07

#include <Phonon/VideoWidget>

08

#include <Phonon/AudioOutput>

09

#include <QUrl>

10

#include <QObject>

11

#include <QVBoxLayout>

12

#include <QHBoxLayout>

13

#include <QLabel>

14

#include <Phonon/VolumeSlider>

15

#include <Phonon/SeekSlider>

16

17

int main(int argc, char *argv[]) {

18

QApplication app(argc, argv);

19

20

QWidget *widget = new QWidget;

21

widget->setWindowTitle(“Media Player”);

22

widget->resize(400,400);

23

24

Phonon::MediaObject *media = new Phonon::MediaObject;

25

media->setCurrentSource(Phonon::MediaSource(“fable.avi”));

26

27

Phonon::VideoWidget *vwidget = new Phonon::VideoWidget(widget);

28

Phonon::createPath(media, vwidget);

29

vwidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto);

30

Phonon::AudioOutput *aOutput = new Phonon::AudioOutput(Phonon::VideoCategory);

31

Phonon::createPath(media, aOutput);

32

33

QLabel *label = new QLabel(“Volume: “);

34

Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;

35

volumeSlider->setAudioOutput(aOutput);

36

volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

37

38

Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider;

39

seekSlider->setMediaObject(media);

40

41

QHBoxLayout *hLayout = new QHBoxLayout;

42

hLayout->addWidget(label);

43

hLayout->addWidget(volumeSlider);

44

hLayout->addStretch();

45

46

QVBoxLayout *vLayout = new QVBoxLayout;

47

vLayout->addWidget(vwidget);

48

vLayout->addWidget(seekSlider);

49

vLayout->addLayout(hLayout);

50

51

widget->setLayout(vLayout);

52

53

widget->show();

54

media->play();

55

return app.exec();

56

}

Permanent link to this article: http://stupidbeauty.com/ShangHaiYanMoJi/2012/01/%e8%bd%ac%e8%bd%bd%ef%bc%9aphonon-%e8%a7%86%e9%a2%91-%e6%92%ad%e6%94%be%e5%99%a8/

十二 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/

旧文章 «