当前位置:网站首页>How to copy and paste QT? (QClipboard)
How to copy and paste QT? (QClipboard)
2022-07-26 00:55:00 【Licht powder】
Here we use QMenu Menu bar to show examples :
QMenu *m_ProgramBtnGroupMenu;
QAction *m_CopyEffectAction;Add operation :
m_ProgramBtnGroupMenu = new QMenu(this);
m_ProgramBtnGroupMenu->addAction(tr(" Copy "), this, SLOT(slotProgramGroupCopy()));
m_CopyEffectAction = m_ProgramBtnGroupMenu->addAction(tr(" Paste "), this, SLOT(slotProgramGroupPost()));
m_CopyEffectAction->setEnabled(false);// Add this sentence , Before copying , The paste is gray
// Restore the operation of the paste button here
connect(QApplication::clipboard(),SIGNAL(dataChanged()), this, SLOT(slotClipDataChange()));void LightEditWidget::slotClipDataChange()
{
QClipboard* clipboard = QApplication::clipboard();
if(clipboard->text().isEmpty()){
m_CopyEffectAction->setEnabled(false);
}else{
m_CopyEffectAction->setEnabled(true);
}
}Copy :
QClipboard* clipboard = QApplication::clipboard();
int iSelectProgramIndex = m_iProgramBtnIndex;
int iStep = m_iCurStep;
QString sText = QString("%1%2").arg(iSelectProgramIndex).arg(iStep);
clipboard->setText(sText);// The content written here is the content pasted later , According to their own needs Get the contents of the pasteboard :
QClipboard* clipboard = QApplication::clipboard();
QString sText = clipboard->text(QClipboard::Clipboard);边栏推荐
- 开放下载!《阿里巴巴 DevOps 实践手册》
- HCIP 第十一天
- 嵌入式开发:技巧和窍门——设计强大的引导加载程序的7个技巧
- Oauth2 and JWT
- Download exclusively | Alibaba cloud maxcompute questions and answers to unlock SaaS mode cloud data warehouse in this electronic manual!
- Tarjan finds the strongly connected component o (n+m), shrinking point
- 如何mysql只要重复数据?
- Azure synapse analytics Performance Optimization Guide (1) -- optimize performance using ordered aggregate column storage indexes
- C#从入门到精通(三)
- 数据写入excel并填充颜色
猜你喜欢

109. 使用 SAP UI5 FileUploader 控件上传本地文件

进程与线程

The ultra comprehensive open source WinForm UI library meets all your desktop development needs!

OAuth2和JWT

【RTOS训练营】程序框架、预习、课后作业和晚课提问

【RTOS训练营】课程学习方法和结构体知识复习 + 链表知识

User defined variables and extracted public variables of JMeter

Hcip day 11

The bumpy road of referencing jar package json-path.jar in jmeter/idea

GOM and GEE engine black screen does not display the interface, and the solution of equipping map monsters
随机推荐
Download exclusively | Alibaba cloud maxcompute questions and answers to unlock SaaS mode cloud data warehouse in this electronic manual!
BGP 综合实验
[oops framework] random number generation management
【RTOS训练营】环形缓冲区、AT指令、预习安排和晚课提问
Seretod2022 track1 code analysis - task-based dialogue system challenge for semi supervised and reinforcement learning
hcia综合实验
Hcip day 11
开放下载!《阿里巴巴 DevOps 实践手册》
编程学习过程中有哪些快速提高编程技巧的方法?
[RTOS training camp] review of the previous section, idle tasks, timer tasks, execution sequence, scheduling strategy and evening class questions
Hcip day 13
Tell you the meaning of unit testing from another angle
RHCE之at和crontab命令详解及chrony部署
使用 SAP UI5 FileUploader 控件上传本地文件试读版
Day06 MySQL knowledge points summary
Hnoi2012 mine construction
[RTOS training camp] operation explanation, queue and ring buffer, queue - transmission data, queue - synchronization tasks and evening class questions
分布式事务和Seata的AT模式原理
JDBC实现MySQL8.0数据库的增删改查
YOLOV3