QT界面开发杂记(一)

三种信号槽的连接方式

 

   connect(button,SIGNAL(clicked(bool)),this,SLOT(openButtonClicked()));
   connect(button,&QPushButton::clicked,this, &Widget::openButtonClicked);
   connect(button,&QPushButton::clicked, this, [=]{
   });

//---------------------------------------i.toLocalFileted特殊字符乱码

else if("addFileUrls" == eventName){
            QStringList list = value.toString().trimmed().split("\n");
            QList 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"<


//----------------------------------------------calculate md5

QString returnMD5 = "";
returnMD5 = QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex();

//-----------------------------------------------get fileData

QFile loadFile(filePath);
bool isOk =loadFile.open(QFile::ReadOnly);
qDebug()<> data;
}


//----------------------------filenotexist

QFileInfo projectInfo(projectPath);
if(!projectInfo.exists()){
}

//--------------------------------show window widthout taskbar
//这样新建的窗口在taskbar没有对应的任务图标,并且不能被关闭,如若需要做桌面悬浮工具栏,可以使用QDockWidget  

QWidget widget;      
widget.setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint |Qt::X11BypassWindowManagerHint);  

//qt中获取文件路径和文件名、后缀名
https://blog.csdn.net/chan_qx/article/details/50950371

//QList转QVariant

QList list1;
list1 << 11 << 22 << 33;
QVariant v = QVariant::fromValue >(list1);

//QVariant转QList

QList list2 = v.value >();

setWindowFlags tool和popup

 tool可以浮在dialog上

popup可以浮在tool上

但是popup会抢占焦点

exec显示的一定会抢占焦点

你可能感兴趣的:(QT,qt)