当前位置:网站首页>【QT源代码复用】QDateTimeEdit的下拉按钮事件响应
【QT源代码复用】QDateTimeEdit的下拉按钮事件响应
2022-07-22 09:12:00 【氺月洞天】
源码中的例子
QStyleOptionComboBox optCombo;
optCombo.init(this);
optCombo.editable = true;
optCombo.subControls = QStyle::SC_All;
if(QStyle::SC_ComboBoxArrow == this->style()->hitTestComplexControl(QStyle::CC_ComboBox, &optCombo, event->pos(), this)) {
源码获取下拉窗口的位置
void QDateTimeEditPrivate::positionCalendarPopup()
{
Q_Q(QDateTimeEdit);
QPoint pos = (q->layoutDirection() == Qt::RightToLeft) ? q->rect().bottomRight() : q->rect().bottomLeft();
QPoint pos2 = (q->layoutDirection() == Qt::RightToLeft) ? q->rect().topRight() : q->rect().topLeft();
pos = q->mapToGlobal(pos);
pos2 = q->mapToGlobal(pos2);
QSize size = monthCalendar->sizeHint();
QRect screen = QApplication::desktop()->availableGeometry(pos);
//handle popup falling "off screen"
if (q->layoutDirection() == Qt::RightToLeft) {
pos.setX(pos.x()-size.width());
pos2.setX(pos2.x()-size.width());
if (pos.x() < screen.left())
pos.setX(qMax(pos.x(), screen.left()));
else if (pos.x()+size.width() > screen.right())
pos.setX(qMax(pos.x()-size.width(), screen.right()-size.width()));
} else {
if (pos.x()+size.width() > screen.right())
pos.setX(screen.right()-size.width());
pos.setX(qMax(pos.x(), screen.left()));
}
if (pos.y() + size.height() > screen.bottom())
pos.setY(pos2.y() - size.height());
else if (pos.y() < screen.top())
pos.setY(screen.top());
if (pos.y() < screen.top())
pos.setY(screen.top());
if (pos.y()+size.height() > screen.bottom())
pos.setY(screen.bottom()-size.height());
monthCalendar->move(pos);
}
边栏推荐
- juju debug hacks (by quqi99)
- 总结20220120
- Js高级-词法作用域
- 04. interface aggregation principle
- [tools] how to set the comparison tool for TortoiseSVN to beyond compare 4
- 01.开闭原则 Open-Closed Principle
- 【STM32】STM32 SDIO SD卡读写测试(三)-- SD_Init之Init Card阶段
- C语言简易TCP服务端程序
- 07.合成复用原则(Composite/Aggregate Reuse Principle,CARP)
- 函数的简介
猜你喜欢
06.里氏替换原则(Liskov Substitution Principle,LSP)
Laravel 解决【1045】Access denied for user ‘homestead‘@‘localhost‘ (usin g password: YES)
【STM32】STM32 SDIO SD卡读写测试(一)-- SD卡硬件设计和软件移植
使用工厂的方法创建对象
TCP与UDP及三次握手,四次挥手
【STM32】STM32 SDIO SD卡读写测试(四)-- SD_Test之Transfer Mode阶段
IP, subnet mask, gateway, IPS and IDS
App mobile End test [6] application (APK) package Management and Activity
Uniapp wechat applet map, open in Gaode app, Tencent app, baidu app, apple map app
Js高级-函数的理解
随机推荐
wampserver搭建到腾讯云服务,localhost能访问到apache,域名也能访问到自带的iis服务器,但域名访问不了
call()和apply()
04. interface aggregation principle
【FatFs】FAT32文件系统协议总结(理论+实践)
web新手区
centos7.5下添加gd库然后mysql拓展库没了mysql拓展的配置也没问题,phpinfo中就是没有mysql拓展
Js高级-函数的理解
使用工厂的方法创建对象
Simple demonstration and prevention of CSRF attack in PHP development
App mobile terminal test [6] application program (APK) package management and activity
No input file specified solution
LeetCode: 185. 部门工资前三高的所有员工
全局作用域和函数作用域
数据湖简单记录
creating vlan over openstack (by quqi99)
Go 管道模式的实际例子——计算一系列文件的 md5 值
PHP实现删除一维数组中某一个值
How can ECSHOP run super slow locally?
Js高级-基本数据类型与引用数据类型
charm zaza functional test (by quqi99)