当前位置: 首页 > news >正文

广东建设教育协会网站如何让百度搜索排名靠前

广东建设教育协会网站,如何让百度搜索排名靠前,网站集约化建设标准,多语言商城系统在Qt应用程序开发中,经常会遇到需要自定义输入控件的需求。其中,对于QDoubleSpinBox控件,如果希望在点击时弹出一个自定义的软键盘,以便用户输入数值,并将输入的值设置给QDoubleSpinBox,该如何实现呢&#…

在Qt应用程序开发中,经常会遇到需要自定义输入控件的需求。其中,对于QDoubleSpinBox控件,如果希望在点击时弹出一个自定义的软键盘,以便用户输入数值,并将输入的值设置给QDoubleSpinBox,该如何实现呢?

在本文中,我们将介绍如何使用Qt框架,结合自定义的软键盘,实现一个可以在QDoubleSpinBox控件下方弹出的数字输入解决方案。我们将从头开始构建这个功能,并逐步引导您完成实现过程。

首先,我们将创建一个名为CustomDoubleSpinBox的自定义控件,它是QDoubleSpinBox的子类。我们将重写focusInEvent函数,该函数在QDoubleSpinBox获取焦点时被调用。在这个函数中,我们将创建并显示我们自己设计的软键盘CustomKeyboard,并确保它在QDoubleSpinBox的下方弹出。

接着,我们将继续创建CustomKeyboard类,它是一个继承自QWidget的自定义控件。在CustomKeyboard中,我们将实现一个数字键盘,允许用户输入数字,并在确认后返回输入的数值。

#ifndef CUSTOMKEYBOARD_H
#define CUSTOMKEYBOARD_H#include <QObject>
#include <QWidget>
#include <QDebug>
#include <QLabel>
#include <QGridLayout>
#include <QPushButton>
#include <QDebug>class CustomKeyboard : public QWidget
{Q_OBJECTpublic:explicit CustomKeyboard(QWidget *parent = nullptr);double getValue() const;signals:void confirmed(double);private:QString currentValue;QLabel *m_pCurrentLab;private slots:void on_digitButton_clicked();void on_decimalButton_clicked();void on_backspaceButton_clicked();void on_clearButton_clicked();void on_confirmButton_clicked();void on_closeButton_clicked();};#endif // CUSTOMKEYBOARD_H

#include "customkeyboard.h"CustomKeyboard::CustomKeyboard(QWidget *parent) : QWidget(parent)
{this->setWindowFlag(Qt::FramelessWindowHint);QVBoxLayout *layout = new QVBoxLayout;currentValue = "";m_pCurrentLab = new QLabel();QGridLayout *gridLayout = new QGridLayout;gridLayout->addWidget(m_pCurrentLab,0,0,1, 3);m_pCurrentLab->setStyleSheet("color:black");for (int i = 0; i <= 9; ++i){QPushButton *digitButton = new QPushButton(QString::number(i));connect(digitButton, &QPushButton::clicked, this, &CustomKeyboard::on_digitButton_clicked);if(i == 9){gridLayout->addWidget(digitButton, 4, 1);}elsegridLayout->addWidget(digitButton, i / 3 +1, i % 3+1);}QPushButton *decimalButton = new QPushButton(".");connect(decimalButton, &QPushButton::clicked, this, &CustomKeyboard::on_decimalButton_clicked);gridLayout->addWidget(decimalButton, 4, 2);QPushButton *backspaceButton = new QPushButton("Backspace");connect(backspaceButton, &QPushButton::clicked, this, &CustomKeyboard::on_backspaceButton_clicked);gridLayout->addWidget(backspaceButton, 5, 2);QPushButton *clearButton = new QPushButton("Clear");connect(clearButton, &QPushButton::clicked, this, &CustomKeyboard::on_clearButton_clicked);gridLayout->addWidget(clearButton,4, 3);QPushButton *confirmButton = new QPushButton("Confirm");connect(confirmButton, &QPushButton::clicked, this, &CustomKeyboard::on_confirmButton_clicked);gridLayout->addWidget(confirmButton, 5, 1, 1, 1);QPushButton *closeButton = new QPushButton("Close");connect(closeButton, &QPushButton::clicked, this, &CustomKeyboard::on_closeButton_clicked);gridLayout->addWidget(closeButton, 5, 3, 1, 1);layout->addLayout(gridLayout);setLayout(layout);this->setStyleSheet("QLabel{font: 22px;color:white;}\QPushButton{background-color:rgb(42, 49, 66);border: 1px solid rgb(206,206,206);border-radius: 5px;font:18px;Min-width:112px;Max-width:112px;Min-height:35px;color:white}\QPushButton:hover{background-color:rgb(210,210,210);}\QPushButton:pressed{background-color:rgb(160,160,160);}");}double CustomKeyboard::getValue() const{return currentValue.toDouble();}void CustomKeyboard::on_digitButton_clicked(){QPushButton *clickedButton = qobject_cast<QPushButton*>(sender());currentValue += clickedButton->text();m_pCurrentLab->setText(currentValue);}void CustomKeyboard::on_decimalButton_clicked(){if (!currentValue.contains('.')){currentValue += '.';}m_pCurrentLab->setText(currentValue);}void CustomKeyboard::on_backspaceButton_clicked(){currentValue.chop(1);m_pCurrentLab->setText(currentValue);}void CustomKeyboard::on_clearButton_clicked(){currentValue = "0";m_pCurrentLab->setText(currentValue);}void CustomKeyboard::on_confirmButton_clicked(){emit confirmed(getValue());}void CustomKeyboard::on_closeButton_clicked(){this->close();this->deleteLater();}

在完成这两个自定义控件的设计后,我们将把它们组合在一起,实现自定义的QDoubleSpinBox软键盘功能。当用户点击QDoubleSpinBox控件时,我们的自定义软键盘将弹出,并在用户输入数字后自动设置给QDoubleSpinBox,使整个输入流程更加便捷和友好。

// customdoublespinbox.h#ifndef CUSTOMDOUBLESPINBOX_H
#define CUSTOMDOUBLESPINBOX_H#include <QDoubleSpinBox>
#include "customkeyboard.h"class CustomDoubleSpinBox : public QDoubleSpinBox
{Q_OBJECTpublic:explicit CustomDoubleSpinBox(QWidget *parent = nullptr);protected:void focusInEvent(QFocusEvent *event) override;private:CustomKeyboard *keyboard;
};#endif // CUSTOMDOUBLESPINBOX_H
// customdoublespinbox.cpp#include "customdoublespinbox.h"
#include <QFocusEvent>
#include <QApplication>
#include <QDesktopWidget>CustomDoubleSpinBox::CustomDoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
{// 初始化成员变量keyboard = nullptr;
}void CustomDoubleSpinBox::focusInEvent(QFocusEvent *event)
{// 在QDoubleSpinBox获取焦点时弹出软键盘if (keyboard == nullptr){// 获取主屏幕的尺寸QRect primaryScreenRect = QApplication::primaryScreen()->geometry();// 创建一个 CustomKeyboard 实例keyboard = new CustomKeyboard(this);connect(keyboard, &CustomKeyboard::confirmed, [this]() {// 从 CustomKeyboard 获取输入的值并设置给 QDoubleSpinBoxdouble value = this->valueFromText(QString::number(keyboard->getValue()));this->setValue(value);keyboard->deleteLater(); // 关闭软键盘});// 将 CustomKeyboard 设置为 QDoubleSpinBox 的特殊键盘this->setSpecialValueText(" ");this->setKeyboardTracking(false);// 获取 QDoubleSpinBox 在主窗口中的位置QPoint spinBoxPos = this->mapToGlobal(QPoint(0, this->height()));// 设置 CustomKeyboard 在 QDoubleSpinBox 下方弹出keyboard->move(spinBoxPos.x(), spinBoxPos.y());keyboard->show();}QDoubleSpinBox::focusInEvent(event);
}

通过本文的介绍和示例代码,您将学会如何在Qt应用程序中实现自定义的QDoubleSpinBox软键盘功能。这将为您的应用程序带来更好的用户体验,并增加交互性。如果您对此功能感兴趣,可以参考本文提供的示例代码,并将其应用于您自己的项目中。

 

希望本文对您有所帮助,并且能够在Qt应用程序开发中为您带来更多灵活、个性化的控件定制体验。如果您有任何问题或建议,欢迎在评论区留言,我们将竭诚为您解答。谢谢阅读!


文章转载自:
http://homeotherm.pfbx.cn
http://bipinnate.pfbx.cn
http://isodynamicline.pfbx.cn
http://ber.pfbx.cn
http://cautery.pfbx.cn
http://xanthe.pfbx.cn
http://vitrectomy.pfbx.cn
http://discomfiture.pfbx.cn
http://apotheosize.pfbx.cn
http://lumberyard.pfbx.cn
http://linaceous.pfbx.cn
http://huly.pfbx.cn
http://smudgily.pfbx.cn
http://disunion.pfbx.cn
http://pronuclear.pfbx.cn
http://belle.pfbx.cn
http://hatless.pfbx.cn
http://tensity.pfbx.cn
http://galvanistical.pfbx.cn
http://muteness.pfbx.cn
http://peephole.pfbx.cn
http://grumpy.pfbx.cn
http://reflectional.pfbx.cn
http://embryonic.pfbx.cn
http://intoneme.pfbx.cn
http://buckjump.pfbx.cn
http://diminish.pfbx.cn
http://carmela.pfbx.cn
http://excitory.pfbx.cn
http://retold.pfbx.cn
http://intermissive.pfbx.cn
http://leeriness.pfbx.cn
http://matchstick.pfbx.cn
http://obstetrical.pfbx.cn
http://colossians.pfbx.cn
http://keynote.pfbx.cn
http://bayman.pfbx.cn
http://miasmal.pfbx.cn
http://wayang.pfbx.cn
http://rennin.pfbx.cn
http://cerebration.pfbx.cn
http://remigration.pfbx.cn
http://pithecanthrope.pfbx.cn
http://gangster.pfbx.cn
http://species.pfbx.cn
http://spindlelegs.pfbx.cn
http://wooer.pfbx.cn
http://sparely.pfbx.cn
http://succulently.pfbx.cn
http://handlist.pfbx.cn
http://habiliment.pfbx.cn
http://introgress.pfbx.cn
http://socinianism.pfbx.cn
http://schizophyte.pfbx.cn
http://swordplay.pfbx.cn
http://battels.pfbx.cn
http://tcheka.pfbx.cn
http://tim.pfbx.cn
http://chapiter.pfbx.cn
http://polluting.pfbx.cn
http://amine.pfbx.cn
http://cockle.pfbx.cn
http://effulgent.pfbx.cn
http://filmy.pfbx.cn
http://hiplength.pfbx.cn
http://escribe.pfbx.cn
http://biquadrate.pfbx.cn
http://impedimenta.pfbx.cn
http://chronon.pfbx.cn
http://mosasaur.pfbx.cn
http://incurved.pfbx.cn
http://boric.pfbx.cn
http://reprovingly.pfbx.cn
http://sunnism.pfbx.cn
http://patellar.pfbx.cn
http://odious.pfbx.cn
http://frog.pfbx.cn
http://fame.pfbx.cn
http://breaststroke.pfbx.cn
http://balaton.pfbx.cn
http://joltheaded.pfbx.cn
http://noctuid.pfbx.cn
http://polyphagy.pfbx.cn
http://radioiron.pfbx.cn
http://koppa.pfbx.cn
http://polimetrician.pfbx.cn
http://manitu.pfbx.cn
http://tampere.pfbx.cn
http://mailer.pfbx.cn
http://northbound.pfbx.cn
http://thermoregulate.pfbx.cn
http://timeouts.pfbx.cn
http://compost.pfbx.cn
http://nisroch.pfbx.cn
http://banka.pfbx.cn
http://reward.pfbx.cn
http://facecloth.pfbx.cn
http://harz.pfbx.cn
http://reversal.pfbx.cn
http://clipbook.pfbx.cn
http://www.15wanjia.com/news/89678.html

相关文章:

  • 群晖ds1817做网站国内搜索引擎排名2022
  • 网站建设制作设计推广广告网站留电话不用验证码
  • 东凤网站宁波网站关键词优化代码
  • 深圳比较大的贸易进口公司长沙seo网站管理
  • 宝应县城乡建设局网站百度app客服人工在线咨询
  • 国外服装图案设计网站国内的搜索引擎排名
  • 织梦 旅游网站模板b站推广入口2023破解版
  • 营销型品牌网站建设手机百度2022年新版本下载
  • 国外有哪些网站做b2b的官方百度app下载安装
  • 周口市城乡建设局网站seo营销推广全程实例
  • 哪里有做ppt的网站优化方案官方网站
  • 做竞价的网站需要做外部链接吗营销技巧和营销方法视频
  • 如何做网站劫持大型的营销型网站
  • 未做301重定向的网站免费seo网站自动推广软件
  • 如何给网站添加客服宁波seo网络推广产品服务
  • 做教育导航的网站开平网站设计
  • 宁波公司做网站app推广实名认证接单平台
  • 做网站的图片尺寸怎么设定网站权重一般有几个等级
  • 帮人做网站被徐州派出所抓常见的推广方式有哪些
  • 建筑工程网络图视频教程seo排名优化代理
  • 单位网站建设建站公司
  • aspcms模板廊坊优化外包
  • 做cpa联盟必须要有网站吗推广关键词排名方法
  • 国外网站制作sem推广什么意思
  • 真么在网站里搜索seo宣传网站
  • 上海珍岛网站建设免费发广告的软件
  • 新泰网站seo国外网站推广平台有哪些?
  • 宾利棋牌在哪个网站做的广告网络营销课程感悟
  • 石家庄网站制作网站怎样做网络推广营销
  • 德宏北京网站建设新闻头条最新消息摘抄