qstyle

Qt6官方最新消息:桌面样式Qt quick Controls 2支持大多控件,委托更少,运行更流畅

天大地大妈咪最大 提交于 2020-11-18 17:38:12
Qt 是一个跨平台框架,通常用作图形工具包,它不仅创建CLI应用程序中非常有用。而且它也可以在三种主要的台式机操作系统以及移动操作系统(如Symbian,Nokia Belle,Meego Harmattan,MeeGo或BB10)以及嵌入式设备,Android(Necessitas)和iOS的端口上运行。现在我们为你提供了免费的试用版。赶快点击 下载Qt最新试用版 吧 >> Qt Quick Controls 1是我们第一个QML的UI框架。这些控件主要是用QML编写的,没有使用太多的C++。当时,QML还是一种新技术,这意味着我们在性能设计方面没有足够的经验,不知道会有什么结果。因此,造型API在设计上最终是低效的,它有很多肥大的委托,在控制逻辑和造型上都使用了大量的JavaScript、绑定、自省、Loaders和QObjects。它还存在对Qt Widgets的链接依赖,以获得本地的样式和基于Widget的对话框。而如果没有我们今天的QML编译器,这一切最终都是一种相当缓慢和混乱的方法。Qt Quick Controls 2是当我们意识到它在嵌入式硬件上的表现也不好时重新考虑解决方案。 Qt Quick Controls 2 对于 Controls 2,我们的基本想法是将大部分的实现从 QML 转移到 C++。通过这样做,我们的目标是尽可能地精简代表,而不是从C+

Qt子类化后qss设置背景色无效的问题

北战南征 提交于 2020-10-02 22:00:47
1、问题背景 在某个类中,用到了一个组合的widget,有按钮进度条等,类似于视频播放器按钮控制区和进度条(参考了很多feiyangqingyun的文章,感谢),调试正常后整理代码,为了提高代码可读性,把widget提到一个单独的类中,重命名为FlowPanel,子类化后发现之前设置的widget背景色无法生效。 2、在父类中直接创建widget控制面板 步骤 1 : 在父控件类中直接创建 widiget : flowPanel2 = new QWidget ( this ); initFlowpanel (); 步骤 2 :调用初始化函数,设置元素和样式 void PlayWidget :: initFlowpanel () { flowPanel2 -> setObjectName ( "flowPanel" ); QHBoxLayout * layout = new QHBoxLayout ; layout -> setSpacing ( 3 ); layout -> setMargin ( 0 ); layout -> addStretch (); flowPanel2 -> setLayout ( layout ); // 按钮集合 QList < QString > btns ; btns << "btnFlowVideo" << "btnFlowSnap" <<

Qt输入框添加搜索按钮,以及自动补全内容

笑着哭i 提交于 2020-08-12 23:23:56
// 输入框添加自动搜索按钮和自动补全控件 void addSerachIconAndCompleterToLineEdit(QLineEdit* lineEdit) { QCompleter * completer = new QCompleter(lineEdit); QStringListModel * stringListModel = new QStringListModel(lineEdit); completer -> setMode(stringListModel); // 显示全部搜索结果 completer-> setCompletionMode(QCompleter::UnfilteredPopupCompletion); lineEdit -> setCompleter(completer); auto searchAction = new QAction(lineEdit); searchAction ->setIcon(QApplication::style()-> standardIcon(QStyle::SP_FileDialogContentsView)); // searchAction->setIcon(":/resource.query.png"); lineEdit-> addAction(searchAction, QlineEdit:

Qt5的插件

♀尐吖头ヾ 提交于 2020-08-09 20:38:49
在定义中使用Q_PLUGIN_METADATA,与qt4的不同 class SimpleStylePlugin : public QStylePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "simplestyle.json") public: SimpleStylePlugin() {} QStringList keys() const; QStyle *create(const QString &key) override; }; 添加Json文件 simplestyle.json { "Keys": [ "simplestyle" ] } 源文件 //! [0] QStringList SimpleStylePlugin::keys() const { return QStringList() << "SimpleStyle"; } //! [0] //! [1] QStyle *SimpleStylePlugin::create(const QString &key) { if (key.toLower() == "simplestyle") return new SimpleStyle; return 0; } QProxyStyle

QTableWidget添加带有复选框的表头

牧云@^-^@ 提交于 2020-05-08 16:29:09
#ifndef SCHECKBOXHEADERVIEW_H #define SCHECKBOXHEADERVIEW_H #include <QtGui> #include <QPainter> #include <QHeaderView> #include <QStyleOptionButton> #include <QStyle> class SCheckBoxHeaderView : public QHeaderView { Q_OBJECT private : bool isChecked; int m_checkColIdx; public : SCheckBoxHeaderView( int checkColumnIndex, Qt::Orientation orientation, QWidget * parent = 0 ) : QHeaderView(orientation, parent) { m_checkColIdx = checkColumnIndex; isChecked = false ; } signals: void checkStausChange( bool ); protected : void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const

qt 界面去掉系统边框

醉酒当歌 提交于 2020-04-20 16:52:12
该代码在Qt5框架编辑,使用该类时, 直接继承这个类就可以了。 实现了拖拽功能和关闭功能,如果需要放大缩小功能, 需自己实现。 1 #ifndef CUSTOMIZE_QWIDGET_H 2 #define CUSTOMIZE_QWIDGET_H 3 #include <QWidget> 4 #include <QMouseEvent> 5 6 class CustomizeQWidget : public QWidget 7 { 8 Q_OBJECT 9 public : 10 explicit CustomizeQWidget(QWidget *parent = 0 ); 11 ~ CustomizeQWidget(); 12 public slots: 13 void on_button_close_clicked(); 14 private : 15 void paintEvent(QPaintEvent * ); 16 void mousePressEvent(QMouseEvent * event ); 17 void mouseMoveEvent(QMouseEvent * event ); 18 private : 19 QPoint m_last_mouse_position; 20 }; 21 #endif // CUSTOMIZE_QWIDGET_H 1

QToolButton with icon + text: How to center both?

陌路散爱 提交于 2020-01-15 18:48:14
问题 I am using multiple QToolButtons in a custom QGridLayout widget. The buttons are set to display icon + text based on an assigned default QAction. The only issue is that the content (icon + text) is always left-aligned. The content (icon + text, marked as a red box in the screenshot), should be center in the button (indicated by the blue box). For most cases this is just fine, given that Qt automatically tries to render that button with the minimal size. However I am stretching the button to

QToolButton with icon + text: How to center both?

青春壹個敷衍的年華 提交于 2020-01-15 18:47:23
问题 I am using multiple QToolButtons in a custom QGridLayout widget. The buttons are set to display icon + text based on an assigned default QAction. The only issue is that the content (icon + text) is always left-aligned. The content (icon + text, marked as a red box in the screenshot), should be center in the button (indicated by the blue box). For most cases this is just fine, given that Qt automatically tries to render that button with the minimal size. However I am stretching the button to

QToolButton with icon + text: How to center both?

大城市里の小女人 提交于 2020-01-15 18:47:13
问题 I am using multiple QToolButtons in a custom QGridLayout widget. The buttons are set to display icon + text based on an assigned default QAction. The only issue is that the content (icon + text) is always left-aligned. The content (icon + text, marked as a red box in the screenshot), should be center in the button (indicated by the blue box). For most cases this is just fine, given that Qt automatically tries to render that button with the minimal size. However I am stretching the button to

HowTo draw QTreeWidgetItem with different style?

淺唱寂寞╮ 提交于 2019-12-24 09:27:57
问题 Here is the main problem : I'm using QTreeWidget class as a main tree, which must show me this tree structure: [Today] [Row1] [Row2] [SubRow21] [SubRow22] [Row3] [Yesterday] [Row4] [SubRow41] [etc] With Qt Designer I have set this style sheet code: QTreeWidget#treeWidget::item { height: 24px; border: none; background-position: bottom left; background-image: url(:/backgrounds/images/backgrounds/row_back.png); } QTreeWidget#treeWidget::item:selected { color: #000000; background-position: bottom