@苏紫方璇
QT中的响铃是这么写的:MessageBeep(MB_OK);
看到了下面的代码,我果断粘过去了奏乐的代码
可以没事的时候搞个 F7 F8 F9 等调试热键,配上1234567的音乐
[C++] 纯文本查看 复制代码
void Bridge::CopyToClipboard(const QString & text)
{
if(!text.length())
return;
QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(text);
GuiAddStatusBarMessage(tr("The data has been copied to clipboard.\n").toUtf8().constData());
QFile file(":/icons/images/egg.wav");
if(file.open(QIODevice::ReadOnly))
{
QByteArray egg = file.readAll();
PlaySoundA(egg.data(), 0, SND_MEMORY | SND_ASYNC | SND_NODEFAULT);
}
}
void Bridge::CopyToClipboard(const QString & text, const QString & htmlText)
{
QMimeData* mimeData = new QMimeData();
mimeData->setData("text/html", htmlText.toUtf8()); // Set text/html data
mimeData->setData("text/plain", text.toUtf8()); //Set text/plain data
//Reason not using setText() or setHtml():Don't support storing multiple data in one QMimeData
QApplication::clipboard()->setMimeData(mimeData); //Copy the QMimeData with text and html data
GuiAddStatusBarMessage(tr("The data has been copied to clipboard.\n").toUtf8().constData());
QFile file(":/icons/images/egg.wav");
if(file.open(QIODevice::ReadOnly))
{
QByteArray egg = file.readAll();
PlaySoundA(egg.data(), 0, SND_MEMORY | SND_ASYNC | SND_NODEFAULT);
}
}
|