linux qt4的qcombobox下拉框,在窗口管理器,开启复合效果后,会跑偏问题

3 篇文章 0 订阅

1. 下载qt4的源码

这里使用的是qt4.8.6网址,http://download.qt.io/archive/qt/4.8/4.8.6/,下载qt-everywhere-opensource-src-4.8.6.tar.gz。

2. 编译qt

a.解压

将qt-everywhere-opensource-src-4.8.6.tar.gz放入/opt目录下

tar -zxvf qt-everywhere-opensource-src-4.8.6.tar.gz

b.生成Makefile

cd qt-everywhere-opensource-src-4.8.6
./configure
make

3. 修改代码

修改文件qt-everywhere-opensource-src-4.8.6/src/gui/widgets/qcombobox.cpp

void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
{
    if (!container)
        return;
    Q_Q(QComboBox);
    QStyleOptionComboBox opt;
    q->initStyleOption(&opt);
#ifndef QT_NO_MENU
    if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
        QMenu menu;
        menu.ensurePolished();
        container->setPalette(menu.palette());
        container->setWindowOpacity(menu.windowOpacity());
    } else
#endif
    {
        container->setPalette(q->palette());
//        container->setWindowOpacity(1.0); //屏蔽这行
    }
    if (lineEdit)
        lineEdit->setPalette(q->palette());
}

4.重新编译

make

5.替换文件

编译后得到新的库文件,在qt-everywhere-opensource-src-4.8.6/lib中,找到libQtGui.so相关文件,并替换原有的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值