Three signal slot connections
connect(button,SIGNAL(clicked(bool)),this,SLOT(openButtonClicked()));
connect(button,&QPushButton::clicked,this, &Widget::openButtonClicked);
connect(button,&QPushButton::clicked, this, [=]{
});
//------------------------------------------ i.toLocalFileted special character garbled
else if("addFileUrls" == eventName){
QStringList list = value.toString().trimmed().split("\n");
QList<QUrl> filesList = QUrl::fromStringList(list);
QStringList sendFilesList;
for (auto i : filesList) {
sendFilesList.append(i.toLocalFile());
}
emit sendFileIDSig(sendFilesList);
}
//qml-c++
//------------------------------------------compressInfoList.format
function startCompressing(files){
console.log("start compressing -----------------------------------------------------", files)
var compressInfoList = {}
compressInfoList.compressFiles = files
compressInfoList.format = "Original"
compressInfoList.quality = 30
compressInfoList.OutputPath = "Source file"
eventManager.sendToWidget("StartCompress", compressInfoList)
}
//--------------------------------------value.toMap()["format"]
else if(eventName == "StartCompress"){//开始压缩
emit signalsstartCompress(value.toMap());
qDebug()<<"value.toMap() --------format"<<value.toMap()["format"];
qDebug()<<"value.toMap() --------format"<<value.toMap()["quality"];
qDebug()<<"value.toMap() --------format"<<value.toMap()["compressFiles"].toStringList();
qDebug()<<"value.toMap() --------format"<<value.toMap()["OutputPath"];
}
//----------------------------------------------calculate md5
QString returnMD5 = "";
returnMD5 = QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex();
//-----------------------------------------------get fileData
QFile loadFile(filePath);
bool isOk =loadFile.open(QFile::ReadOnly);
qDebug()<<filePath<<isOk;
if(isOk){
QDataStream stream(&loadFile);
stream >> data;
}
//----------------------------------filenotexist
QFileInfo projectInfo(projectPath);
if(!projectInfo.exists()){
}
//-------------------------------show window widthout taskbar
//This new window has no corresponding task in the taskbar Icon, and cannot be closed, if you need to make desktop floating toolbar, you can use QDockWidget
QWidget widget;
widget.setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint |Qt::X11BypassWindowManagerHint);
//Get the file path, file name and suffix in qt
https://blog.csdn.net/chan_qx/article/details/50950371
//QList to QVariant
QList<int> list1;
list1 << 11 << 22 << 33;
QVariant v = QVariant::fromValue<QList<int> >(list1);
//QVariant to QList
QList<int> list2 = v.value<QList<int> >();
setWindowFlags tool和popup
tool can float on the dialog
popup can float on the tool
But the popup will grab the focus
The exec display will definitely grab the focus