当前位置:网站首页>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);边栏推荐
- Curd used by hyperf
- What is the difference between request forwarding and request redirection?
- HCIP第十二天
- MMOCR使用指南
- 【RTOS训练营】课程学习方法和C语言知识(指针、结构体、函数指针、链表)和学员问题
- OAuth2和JWT
- GOM and GEE engine black screen does not display the interface, and the solution of equipping map monsters
- Unityvr -- robot arm scene 4- gifts and Christmas tree
- 从另一个角度告诉你单元测试的意义
- 力扣记录:剑指offer(2)——JZ13-22
猜你喜欢
随机推荐
使用 SAP UI5 FileUploader 控件上传本地文件试读版
【RTOS训练营】上节回顾、空闲任务、定时器任务、执行顺序、调度策略和晚课提问
Using questpdf operation to generate PDF is faster and more efficient!
【RTOS训练营】设备子系统、晚课学员提问
DC-6 -- vulnhub range
[RTOS training camp] continue the program framework, tick interrupt supplement, preview, after-school homework and evening class questions
Tell you the meaning of unit testing from another angle
RHCE之at和crontab命令详解及chrony部署
Force deduction record: Sword finger offer (2) -- jz13-22
pip install --upgrade can‘t find Rust compiler
【MATLAB appdesigner】27_ How to debug and view variables in appdesigner? (examples + skills)
Regular expression
Seretod2022 track1 code analysis - task-based dialogue system challenge for semi supervised and reinforcement learning
How can a team making facial mask achieve a revenue of more than 1 million a day?
[RTOS training camp] equipment subsystem, questions of evening students
SQL statement exercise
爬虫小操作
用 QuestPDF操作生成PDF更快更高效!
Tarjan finds the strongly connected component o (n+m), shrinking point
Oauth2 and JWT









