[Share Experiences] 解决QSpinBox宽度不足等
Tofloor
poster avatar
海天鹰
deepin
2021-02-20 04:39
Author

Deepin20主题魔改引起的问题:

 

1.QSpinBox宽度不足

 

2.QTableWidget->resizeColumnsToContents(); 宽度适应内容后,宽度仍然不足,以省略号显示。

 

@maicss 提供的解决方案:使用Qt内置主题(覆盖DDE主题)

1.首先查看Qt有哪几个内置主题:

qDebug() << QStyleFactory::keys();
// ("chameleon", "Windows", "Fusion")

2.然后可以在代码里设置,两种方法都可以:

QApplication::setStyle(QStyleFactory::create("Fusion"));
//a.setStyle(QStyleFactory::create("Fusion"));

还有一个更简单的方法:带参数启动

./app -style Fushion

 

失去的功能:

QSlider点击定位

Reply Favorite View the author
All Replies
神末shenmo
deepin
Spark-App
Q&A Team
2021-02-20 06:11
#1

mystiq -style Fushion
QApplication: invalid style override passed, ignoring it.

Reply View the author
Hello
deepin
2021-02-20 21:00
#2
神末shenmo

mystiq -style Fushion
QApplication: invalid style override passed, ignoring it.

主题名字叫fusion,小写

Reply View the author
偕臧
deepin
2021-02-24 01:29
#3

直接换肤柑橘不算是一个很优雅的方式;个人更推荐  https://github.com/xmuli/lfxNet/blob/master/dde-dock-plugin/WinDdeDockSetting.cpp#L51


	    // 控件的基本设置,其读写留其它函数完成
//    auto list = this->findChildren();  // 切换为上下按钮模式
//    for (auto v : list)
//        v->setProperty("_d_dtk_spinBox", true);
 这个属性可以更改 原生 的 QSpinBox 效果;其后面的那个 + 、- 过于占位置的情况;使用 上下按钮来替换,但也是 DTK 风格,会比较好点。
Reply View the author