共 27 篇文章 |
|
Qt中的键盘事件。bool QKeyEvent::matches ( QKeySequence::StandardKey key ) const如果导致键盘QT事件的按键编码值和参数key所给出的标准按键值匹配则返回true,否则返回false.该函数在QT4.2中有介绍。quint32 QKeyEvent::nativeVirtualKey () const返回导致键盘QT事件的虚拟键或者字符码,如果该键盘事件没有包含该按键的编码则返回0.附注:... 阅157 转0 评0 公众公开 20-02-26 15:11 |
QT 如何设置 QPushButton 的背景色 .//弹出颜色选择框。QPalette pal = ui->pushButton_BackGroundColor->palette();QPalette pal = ui->pushButton_5->palette();ui->pushButton_GoToProcess->setStyleSheet("QPushButton{background-color:black;\"QPushButton:hover{background-color:white; color: black;}&qu... 阅1481 转3 评0 公众公开 19-09-28 10:40 |
#include "widget.h"#include "ui_widget.h"#include <QPalette>#include <QDebug>Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this); 阅280 转1 评0 公众公开 19-09-28 10:36 |
connect(this, SIGNAL(sig_firt()), m_pMyThread, SLOT(first()), Qt::QueuedConnection);//mythread 发出信号 connect(m_pMyThread, SIGNAL(sig_sendfirst()), this, SLOT(slot_recivefirst()), Qt::QueuedConnection); connect(m_pMyThread, SIGNAL(sig_sendsecond()), this, SLOT(slot_recivesecond()), Qt::QueuedConnection); co... 阅555 转1 评0 公众公开 19-08-16 19:21 |
if (m_orien == PWB::Horizontal) { pos.setX(m_pButton->mapToGlobal(QPoint(0, 0)).x() + m_pButton->width());} // 同时只能显示一个 popupwidget foreach (auto widget, m_pWidgets) { if (widget != m_pMainWidget) { widget->hide(); } } m_pMainWidget->move(pos); m_pMainWidget->show(); } else { m_pMainWidget->h... 阅1101 转0 评0 公众公开 19-06-29 07:29 |
如果我们想每次按钮点击的时候都将按钮的Check状态设置为true,在mousePressEvent或者onMousePress或者mouseReleaseEvent方法中去调用setChecked(true),那么在nextCheckState方法中会调用setChecked(!isChecked());我们在给QToolButton进行设置setPopupMode(QToolButton::MenuButtonPopup);(带弹出式菜单)时,再设置一个菜单变量setMenu(... 阅305 转1 评0 公众公开 19-06-29 07:25 |
widget.h.#ifndef WIDGET_H#define WIDGET_H#include <QWidget>QT_BEGIN_NAMESPACEclass QLabel;}class Widget : public QWidget{ Q_OBJECTpublic: explicit Widget(QWidget *parent = 0);#include "widget.h"#include "ui_widget.h"#include <QLabel>#include <QMouseEvent>#include <QDebug>Wid... 阅809 转0 评0 公众公开 19-06-25 22:57 |
在Qt5.4中如何实现QOpenGLWidget和QPainter混合编程。在Qt5.4的Example中,有一个例子qopenglwidget,介绍了QOpenGLWidget和QPainter,但是在使用过程中,需要注意哪些方面呢?第一种方法,也就是直接QOpenGLWidget的paintGL函数中绘制两者,其步骤为:其步骤为:首先,重载两个函数paintGL、paintEvent;第二种方法,比较适合扩展,无需改动原... 阅1783 转3 评0 公众公开 19-06-25 17:30 |
如果大家都是跟我一样,刚刚开始接触QT,开始开发QT的程序,肯定也会有很多不习惯的地方,今天我重点想谈的就是这么一个不习惯的地方--QT中窗口刷新事件。Paint这个事件只要是窗体部件需要被重绘了就会被调用,是由窗体系统产生的,但要求程序重画窗体部件的时候,事件循环就会从事件队列里面选中这个事件并把它分发到那个需要重画的widget中。... 阅451 转0 评0 公众公开 19-06-23 19:29 |
Qt:鼠标事件和滚轮事件。鼠标的组成除了鼠标之外还有滚轮,同时滚轮的滚动也有自己的事件。#include "widget.h"#include "ui_widget.h"#include <QMouseEvent>Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget){ ui->setupUi(this);在滚轮事件的处理函数中,使用QWheelEvent类的delta()... 阅1301 转2 评0 公众公开 19-06-21 23:05 |