当前位置:网站首页>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);边栏推荐
- 进程与线程
- Seretod2022 track1 code analysis - task-based dialogue system challenge for semi supervised and reinforcement learning
- It will be easier to implement MES system by doing well in these four stages
- ASP. Net core configuration
- 【RTOS训练营】I2C和UART知识和预习安排 + 晚课提问
- Leetcode notes 121. the best time to buy and sell stocks
- Processes and threads
- Amin's confession
- SQL statement exercise
- We have no way out
猜你喜欢

Download exclusively | Alibaba cloud maxcompute questions and answers to unlock SaaS mode cloud data warehouse in this electronic manual!

Set set learning

Redis Command Reference Manual - key

Unityvr robot Scene 3 gripper

【RTOS训练营】I2C和UART知识和预习安排 + 晚课提问

【RTOS训练营】站在更高的角度学习C语言

【RTOS训练营】环形缓冲区、AT指令、预习安排和晚课提问

什么是信息化?什么是数字化?这两者有什么联系和区别?

C#从入门到精通(三)

从另一个角度告诉你单元测试的意义
随机推荐
[laser principle and application-4]: internal structure and working principle of laser
开发还没联调,任务就要上线
[plaything determination scratch children programming] ride a small motorcycle (dynamic background + camera control operation)
从另一个角度告诉你单元测试的意义
爬虫小操作
Attack and defense world web question -favorite_ number
[GOM engine] script setting method for dummy configuration
How to choose social e-commerce model in the early stage? Taishan crowdfunding
【RTOS训练营】程序框架、预习、课后作业和晚课提问
[RTOS training camp] equipment subsystem, questions of evening students
[RTOS training camp] program framework, preview, after-school homework and evening class questions
Tell you the meaning of unit testing from another angle
Amin's confession
如何才能修炼成一名不可替代的程序员?
【RTOS训练营】上节回顾、空闲任务、定时器任务、执行顺序、调度策略和晚课提问
我们没有退路了
jupyter更改默认浏览器的方法
以数据驱动管理转型,元年科技正当时
Processes and threads
阿明的告白