精华内容
下载资源
问答
  • QT UI界面组件介绍

    千次阅读 2020-03-10 23:46:37
    1.布局类(4种) ...Th1: Group Box类似于win7的日历框 Th3: Tool Box类似于QQ的好友列表 Th4: Tab widget类似于 5.输入窗() 6.显示窗() 参考链接https://blog.csdn.net/alzzw/article...

    1.布局类(4种)

    2.固定弹簧类(2种)(不随布局变化)

    3.按钮类(6种)

    4.容器类(10种)

    Th1: Group Box类似于win7的日历框

    Th3: Tool Box类似于QQ的好友列表

    Th4: Tab widget类似于

    5.输入窗()

    6.显示窗()

    参考链接https://blog.csdn.net/alzzw/article/details/99636161

     

    展开全文
  • Qt 自定义日历控件

    2020-01-16 17:50:33
    1.ui 界面 2.运行界面 3.源代码 //.h头文件 #ifndef MYCALENDAR_H #define MYCALENDAR_H #include <QWidget> #include <QCalendarWidget> #include <QTextFormat> #include <...

    1.ui 界面

    2.运行界面 

    3.源代码 

     

    //.h头文件
    
    #ifndef MYCALENDAR_H
    #define MYCALENDAR_H
    
    #include <QWidget>
    #include <QCalendarWidget>
    #include <QTextFormat>
    #include <QPushButton>
    
    namespace Ui {
    class MyCalendar;
    }
    
    //自定义日历类
    class MyCalendar : public QWidget
    {
        Q_OBJECT
    
    public:
        explicit MyCalendar(QWidget *parent = 0);
        ~MyCalendar();
    
    private:
        Ui::MyCalendar *ui;
    
    signals:
        void signal_clickLeftYearButton();
        void signal_clickRightYearButton();
        void signal_clickLeftMonthButton();
        void signal_clickRightMonthButton();
    
    public Q_SLOTS:
        void slot_leftYearButtonClicked();
        void slot_rightYearButtonClicked();
        void slot_leftMonthButtonClicked();
        void slot_rightMonthButtonClicked();
    
    public:
        void createNewButton();
    
        //设置当前的日期
        void setCurrentData(QDate pData);
    
        //获取当前的日期
        QDate getCurrentData();
    
    private:
        QCalendarWidget *p_widget;
    
        QPushButton * m_leftYearButton;
        QPushButton * m_rightYearButton;
        QPushButton * m_leftMonthButton;
        QPushButton * m_rightMonthButton;
    
        QPushButton * m_middleYearButton;
        QPushButton * m_middleMonthButton;
    
        QString m_strstyleSheet;
    
    };
    
    #endif // MYCALENDAR_H
    
    
    //.cpp文件
    #include "MyCalendar.h"
    #include "ui_MyCalendar.h"
    #include <QGraphicsDropShadowEffect>
    #include <QDebug>
    
    //日历属性
    const QString g_strCalendarStyle = "QCalendarWidget QTableView\
    {\
    alternate-background-color:rgb(255,255,255);\
    background-color:rgb(255,255,255);\
    font: 18px \"微软雅黑\" #606266;\
    }\
    QCalendarWidget QAbstractItemView:enabled\
    {\
    font-size:18px;color:#606266;\
    selection-background-color:rgb(255, 255, 255);\
    selection-color:#2E8DED;\
    }\
    QCalendarWidget QAbstractItemView:disabled\
    {\
    color:#CFD4D9;\
    }\
    QToolButton#qt_calendar_monthbutton,#qt_calendar_yearbutton\
    {\
    min-height:18px;\
    max-height:18px;\
    min-width:20px;\
    max-width:20px;\
    color:rgb(60,60,60);\
    font: 18px \"微软雅黑\" #606266;\
    background-color:rgb(255,255,255);\
    border:none;\
    }\
    QCalendarWidget QWidget#qt_calendar_navigationbar\
    {\
    background-color:rgb(0,255,255);\
    }\
    QCalendarWidget QMenu\
    {\
    border:none;\
    width:58px;\
    color:rgb(0,85,255);\
    font: 18px \"黑体\";\
    background-color:rgb(175,175,175);\
    text-align:center;\
    selection-background-color:rgb(150,150,150);\
    }\
    QToolButton::menu-indicator\
    {\
    border: 0px;\
    }";
    
    
    MyCalendar::MyCalendar(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::MyCalendar)
    {
        ui->setupUi(this);
        setAutoFillBackground(false);
        setAttribute(Qt::WA_TranslucentBackground, true);
    
        p_widget = new QCalendarWidget(this);
        p_widget->setStyleSheet(g_strCalendarStyle);
    
        QTextCharFormat temp_format;
        QColor color(60, 60, 60);
        temp_format.setForeground(color);
    
        p_widget->setWeekdayTextFormat(Qt::Saturday, temp_format);
        p_widget->setWeekdayTextFormat(Qt::Sunday, temp_format);
        p_widget->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
        p_widget->setHorizontalHeaderFormat(QCalendarWidget::NoHorizontalHeader);
        p_widget->setMinimumSize(230, 190);
        p_widget->setFocusPolicy(Qt::NoFocus);
        p_widget->setFirstDayOfWeek(Qt::Sunday);
        p_widget->setLocale(QLocale::Chinese);
        p_widget->setNavigationBarVisible(false);
    
        ui->widget->setMinimumHeight(35);
    
        QGridLayout* layout = new QGridLayout;
        layout->addWidget(p_widget);
        layout->setContentsMargins(3,3,6,3);
        ui->widget_3->setLayout(layout);
    
        createNewButton();
    
        connect(m_leftMonthButton, SIGNAL(clicked()), this, SLOT(slot_leftMonthButtonClicked()));
        connect(m_rightMonthButton, SIGNAL(clicked()), this, SLOT(slot_rightMonthButtonClicked()));
        connect(m_leftYearButton, SIGNAL(clicked()), this, SLOT(slot_leftYearButtonClicked()));
        connect(m_rightYearButton, SIGNAL(clicked()), this, SLOT(slot_rightYearButtonClicked()));
    }
    
    MyCalendar::~MyCalendar()
    {
        delete ui;
    }
    
    
    void MyCalendar::createNewButton()
    {
        m_middleYearButton = new QPushButton(this);
        m_middleYearButton->setFocusPolicy(Qt::NoFocus);
        m_middleYearButton->move(87, 12);
        m_middleYearButton->setFixedWidth(80);
        m_middleYearButton->setFixedHeight(30);
        m_middleYearButton->setText(QString("%1年").arg(p_widget->yearShown()));
        setObjectName("m_middleYearButton");
        m_middleYearButton->setStyleSheet("background-color:rgb(255,255,255);border:none;\
    font: 20px \"微软雅黑\" #606266;");
    
    
        m_middleMonthButton = new QPushButton(this);
        m_middleMonthButton->setFocusPolicy(Qt::NoFocus);
        m_middleMonthButton->move(156, 12);
        m_middleMonthButton->setFixedWidth(40);
        m_middleMonthButton->setFixedHeight(30);
        m_middleMonthButton->setText(QString("%1月").arg(p_widget->monthShown()));
        setObjectName("m_middleMonthButton");
        m_middleMonthButton->setStyleSheet("background-color:rgb(255,255,255);border:none;\
    font: 20px \"微软雅黑\" #606266;");
    
        m_leftMonthButton = new QPushButton(this);
        m_leftMonthButton->setFocusPolicy(Qt::NoFocus);
        m_leftMonthButton->move(57, 21);
        m_leftMonthButton->setFixedWidth(7);
        m_leftMonthButton->setFixedHeight(12);
        setObjectName("m_leftMonthButton");
        m_leftMonthButton->setStyleSheet("background-color:rgb(255,255,255);border:none;\
     border-image:url(D:/leftMonth.png);");
    
        m_rightMonthButton = new QPushButton(this);
        m_rightMonthButton->setFocusPolicy(Qt::NoFocus);
        m_rightMonthButton->move(220, 21);
        m_rightMonthButton->setFixedWidth(7);
        m_rightMonthButton->setFixedHeight(12);
        setObjectName("m_rightMonthButton");
        m_rightMonthButton->setStyleSheet("background-color:rgb(255,255,255);border:none;\
     border-image:url(D:/rightMonth.png);");
    
        m_leftYearButton = new QPushButton(this);
        m_leftYearButton->setFocusPolicy(Qt::NoFocus);
        m_leftYearButton->move(28, 21);
        m_leftYearButton->setFixedWidth(11);
        m_leftYearButton->setFixedHeight(12);
        setObjectName("m_leftYearButton");
        m_leftYearButton->setStyleSheet("background-color:rgb(255,255,255);border:none;\
    border-image:url(D:/leftYear.png);");
    
        m_rightYearButton = new QPushButton(this);
        m_rightYearButton->setFocusPolicy(Qt::NoFocus);
        m_rightYearButton->move(246, 21);
        m_rightYearButton->setFixedWidth(11);
        m_rightYearButton->setFixedHeight(12);
        setObjectName("m_rightYearButton");
        m_rightYearButton->setStyleSheet("background-color:rgb(255,255,255);border:none;\
    border-image:url(D:/rightYear.png);");
    }
    
    
    void MyCalendar::setCurrentData(QDate pData)
    {
        m_middleYearButton->setText(QString("%1年").arg(pData.year()));
        m_middleMonthButton->setText(QString("%1月").arg(pData.month()));
        p_widget->setSelectedDate(pData);
    }
    
    
    QDate MyCalendar::getCurrentData()
    {
        return p_widget->selectedDate();
    }
    
    
    void MyCalendar::slot_leftYearButtonClicked()
    {
        m_middleYearButton->setText(QString("%1年").arg(p_widget->yearShown() - 1));
        p_widget->showPreviousYear();
    }
    
    
    
    void MyCalendar::slot_rightYearButtonClicked()
    {
        m_middleYearButton->setText(QString("%1年").arg(p_widget->yearShown() + 1));
        p_widget->showNextYear();
    }
    
    
    void MyCalendar::slot_leftMonthButtonClicked()
    {
        if (p_widget->monthShown() != 1)
        {
            m_middleMonthButton->setText(QString("%1月").arg(p_widget->monthShown() - 1));
        }
        else
        {
            m_middleMonthButton->setText(QString("%1月").arg(12));
        }
    
        p_widget->showPreviousMonth();
    }
    
    
    
    void MyCalendar::slot_rightMonthButtonClicked()
    {
        if (p_widget->monthShown() != 12)
        {
            m_middleMonthButton->setText(QString("%1月").arg(p_widget->monthShown() + 1));
        }
        else
        {
            m_middleMonthButton->setText(QString("%1月").arg(1));
        }
    
    
        p_widget->showNextMonth();
    }
    
    

     

    展开全文
  • 对象指针m_caledar QCalendarWidget *m_...m_caledar = new QCalendarWidget(ui.m_widget_DOB_2); /获取当前语种/ SystemLanguageConfigModel* p_system_language_config = NULL; p_system_language_config = Get...

    对象指针m_caledar
    QCalendarWidget *m_caledar = NULL;

    m_caledar = new QCalendarWidget(ui.m_widget_DOB_2);

    /获取当前语种/
    SystemLanguageConfigModel* p_system_language_config = NULL;
    p_system_language_config = GetGlobalSystemLanguageConfigModel();
    QString system_language_static = p_system_language_config->GetLanguage();
    if (system_language_static == “en”)
    {
    m_caledar->setLocale(QLocale::English);
    }
    else
    {
    m_caledar->setLocale(QLocale::Chinese);
    }

    展开全文
  • QCalendarWidget日历设置QCalendarWidget基本设置QCalendarWidget QSS设置 QCalendarWidget基本设置 ui.calendarWidget->setStyleSheet("#calendarWidget{Margin-top:8px;}"); ui.calendarWidget->...

    QCalendarWidget基本设置

        ui.calendarWidget->setStyleSheet("#calendarWidget{Margin-top:8px;}");
        ui.calendarWidget->setNavigationBarVisible(false);//隐藏导航条
        ui.calendarWidget->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);//去掉列表头
        //ui.calendarWidget->setHorizontalHeaderFormat(QCalendarWidget::LongDayNames);//将表头周几显示成星期几
    

    设置日期风格

         QTextCharFormat format;
        format.setForeground(QColor(141, 162, 189));
        format.setFontFamily("Microsoft YaHei");
        format.setFontPointSize(14);
        format.setFontWeight(QFont::Medium);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Monday, format);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Tuesday, format);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Wednesday, format);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Thursday, format);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Friday, format);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Saturday, format);
        ui.calendarWidget->setWeekdayTextFormat(Qt::Sunday, format);
    

    QCalendarWidget QSS设置

    QToolButton#qt_calendar_monthbutton,#qt_calendar_yearbutton{
    	color: #ffffff; 
    	font: 14pt;
    	font-family: 'Microsoft YaHei'; 
    }
    QCalendarWidget QWidget#qt_calendar_navigationbar{
    	background-color: #2d4662;
    	border:2px solid #2d4662;
    }
    QCalendarWidget QMenu{
    	background-color:#8da2bd;font-size:14px;font-family:'Microsoft 	 YaHei';color:#ffffff;
    }
    QCalendarWidget QSpinBox{
    	background-color:#2d4662;font-size:14px;font-family:'Microsoft YaHei';color:#ffffff;
    }
    QCalendarWidget QSpinBox::up-button{
    	image: url(zgx_icon/jckjys/QSpinBox/spinup_normal.png);width:15px;
    }
    QCalendarWidget QSpinBox::up-button:hover{
    	image:url(zgx_icon/jckjys/QSpinBox/spinup_hover.png);
    }
    QCalendarWidget QSpinBox::up-button:pressed{
    	image: url(zgx_icon/jckjys/QSpinBox/spinup_pressed.png);width:15px;
    }
    QCalendarWidget QSpinBox::down-button{
    	image: url(zgx_icon/jckjys/QSpinBox/spindown_normal.png);width:15px;
    }
    QCalendarWidget QSpinBox::down-button:hover{
    	image: url(zgx_icon/jckjys/QSpinBox/spindown_hover.png);
    }
    QCalendarWidget QSpinBox::down-button:pressed{
    	image: url(zgx_icon/jckjys/QSpinBox/spindown_pressed.png);
    }
    QToolButton#qt_calendar_monthbutton{
    	padding-right:20px;
    }
    QToolButton#qt_calendar_prevmonth{
    	icon-size:10px 10px;
    	border:0px;
    	qproperty-icon: url(zgx_icon/jckjys/QCalendar/left_normal.png);
    	Margin-left:10px;
    }
    
    QToolButton#qt_calendar_prevmonth:hover{
    	image:url(zgx_icon/jckjys/QCalendar/left_hover.png);
    }
    QToolButton#qt_calendar_prevmonth:pressed{
    	image: url(zgx_icon/jckjys/QCalendar/left_checked.png);
    
    }
    QToolButton#qt_calendar_nextmonth{
    	icon-size:10px 10px;
    	border:0px;
    	qproperty-icon: url(zgx_icon/jckjys/QCalendar/right_normal.png);
    	Margin-right:10px;
    }
    QToolButton#qt_calendar_nextmonth:hover{
    	image: url(zgx_icon/jckjys/QCalendar/right_hover.png);
    }
    QToolButton#qt_calendar_nextmonth:pressed{
    	image: url(zgx_icon/jckjys/QCalendar/right_checked.png);
    }
    QToolButton#qt_calendar_monthbutton::menu-indicator{
    	subcontrol-origin: padding;
    	subcontrol-position: center right;
    	right: 0px;
    	width: 10px;
    }
    QAbstractItemView {
        color: #bed6fa;
        font-family: 'Microsoft YaHei'; 
        selection-color: rgb(245,251,251);
        selection-background-color: #34c0be;
        font: 14px;
    }
    
    展开全文
  • QT——UI封装类

    2019-10-26 22:59:02
    1.Buttons按钮类简介: ①radio Button:单选框,只允许一个 ②check Box:复选框,...①group Box:类似日历一样矩形的空间容器 ②Scroll Area:类似网页页面可以左右上下滚动的容器 ③Tool Box:抽屉式的容器...
  • ui->calendarWidget->setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames); ui->calendarWidget->setLocale(QLocale::Chinese); Qt日历样式设置参考: Qt日历样式设置参考——公孙二狗
  • QT之QDateTimeEdit触发日历

    千次阅读 2018-04-20 15:36:16
    1、QDateTimeEdit触发日历QSize sz = ui-&gt;dateTimeEdit-&gt;geometry().size() -= QSize(3, 3);QPoint pt(sz.width(), sz.height());QMouseEvent evt(QEvent::MouseButtonPress, pt, Qt::LeftButton, Qt:...
  • Qt学习十:日历组件

    千次阅读 2016-06-30 17:52:14
    日历组件 qtButton.h如下: #ifndef QTBUTTON_H ...#include "ui_qtbutton.h" //---------日历组件---------------------- #include #include #include class qtButton : public QMainWindow {
  • qt dateedit以日历形式显示

    千次阅读 2017-09-19 10:57:39
    ui->dateedit->setCalendarPopup(true);
  • QCalendarWidget *pCalendarWidget = ui.dateEditBegin->calendarWidget(); QTextCharFormat f =pCalendarWidget->weekdayTextFormat(Qt::Monday);//获取周一字体格式 f.setForeground( QBrush(QColor("#0...
  • 刚开始做项目时因为要控制版面大小所以想把日历能够缩减到最小尺寸,然后在网上找了很多怎么修改Qt日历的介绍,发现有些分享的资料里星期栏是显示一二三。。。这样子的,但是怎么样都没有找到怎么设置。后来在一次...
  • 一个基于 C++/Qt日历客户端。 当前主界面(月视图)效果: UI界面采用 Qt Quick/ Qml 绘制 程序整体基于 和 ,皆为 Qt 未正式面世的模块,后者会在 面世,至于前者,似乎还远。 ##当前进度: ####正在解决: 周...
  • !...[图片说明](https://img-ask.csdn.net/upload/202009/01/1598931941_209501.png)就像图片一样,只有鼠标放到那个位置才显示出来,代码就写了一行ui->dateEdit_rectime->... QT版本是5.5.1的。请求大神赐教,谢谢
  • QT:::日历选择并显示

    2019-07-20 10:12:44
    //////////日历选择的日期///////////////////////////////////////// /////点击日历在上面的文本框中显示出来 QObject::connect(ui.calendarWidget, &QCalendarWidget::clicked, [this]() { QDate dt = ...
  • QT5.14入门教程GUI(七)第7个QT程序-日期-时间-日历控件QDate-QTime-QCalendar 1、新建项目,改名称7DateTime; 2、改类名 3、打开UI界面,双击; 4、找到左侧,按钮,如下;单击,拖到右侧界面中...
  • 1、qlabel对齐方式: ui->label->setWordWrap(true); //自动换行 ui->label->setAlignment(Qt::AlignTop);...2、dateEdit显示日历ui -> dateEdit->setDateTime(QDateTime::currentDa
  • class56.ui

    2020-05-18 12:19:30
    QTdesigner】课时56.日历控件(QCalendarWidget)【pyqt5+QTdesigner模式】
  • 自定义日历选择控件

    2021-04-05 22:26:08
    背景:在开放一款嵌入式软件时涉及到数据操作需要按照日期来查询的,QT内置控件不好点,用户操作起来体验很差,所以写了这个自定义日历控件 说明:单击上下按钮切换当前数字,年月日已绑定变化,根据每年每月有多少天...
  • QtDesigner ,各种控件, 控件的设置,如日历的坐标,大小,显示方式等 以ui语言保存 ui界面->可视化拖动各种控件->利用pyuic转化为代码语言 self.calendarWidget = QtWidgets.QCalendarWidget(Form) self....
  • from PyQt5 import QtCore, QtGui, QtWidgets import sys class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(200, 100...
  • ubuntu 通过QT修改操作系统时间

    千次阅读 2013-12-24 10:40:01
    最近做一个项目,其中涉及到系统日期时间设置,刚开始也检索和查阅了不少书籍和网贴,但都没有给出清晰可行... QDateTime dt = ui->dateTimeEditor->dateTime(); //获取日历控件上用户新设置的日期和时间  time_t tt
  • 7.13 Qt的日期、时间、日历等控件 169 QDateEdit控件 169 QDateTimeEdit控件 169 QCalendarWidget控件 170 7.14 QDialog 171 简介 171 操作 171 QMessageBox 172 QFileDialog 173 QFontDialog 174 QColorDialog 175
  • QDate对象包含日历日期,即年,月,日的数字。它可以从系统时钟读取当前日期,提供了比较日期和操作日期的功能。例如,可以在日期中添加和减去天,月和年。QTime对象包含一个时钟时间,即自午夜的小时,分钟,秒和...
  • QCalendarWidget使用用例总结

    千次阅读 2019-04-23 17:06:28
    QT系统自带日历控件 QCalendarWidget *m_caledar = NULL; //日历控件 m_caledar = new QCalendarWidget(ui.m_widget_DOB_2); m_caledar->setGeometry(0, 0, 303, 197);//高度一定不能小于197,否则显示不全...

空空如也

空空如也

1 2
收藏数 25
精华内容 10
关键字:

qtui日历