forgot to setup the environment using 'qmake -projects'
-
trying to post some new Complie Output errors but keep getting this forum error:
ErrorPost content was flagged as spam by Akismet.com
-
Try to post a reduced version of the compiler error.
-
new build error:
regarding ".exactMatch" deprecated in Qt6 so i added #include QRegExp in mainwindow.h
which required "core5compat" to be added to QT += core gui network core5compat in ImageViewer.prooriginal offending ".exactMatch" in mainwindow.cpp file.
fileNames = dialog.selectedFiles();
if(QRegExp(".+\.(png|bmp|jpg)").exactMatch(fileNames.at(0))) {
currentImage->pixmap().save(fileNames.at(0));i tried to fix with: "(QRegExp::pattern(fileNames.at(0))) "
which is causing Compile Output error of, a regular expression compatibility with a boolean.
so should "(QRegularExpression(".+\.(png|bmp|jpg" be put inside of (QRegExp::pattern() ???[ maybe the proper solution is to build this book example in Qt5 instead of trying to adapt it to build in Qt6 ????]
is that easy to do ???".exactMatch" is discontinued in Qt6 so i am trying "QRegExp::pattern"
if(QRegularExpression(".+\\.(png|bmp|jpg)") (QRegExp::pattern(fileNames.at(0))) { currentImage->pixmap().save(fileNames.at(0)); } else { QMessageBox::information(this, "Information", "Save error: bad format or filename.");
-
@uglybug said in forgot to setup the environment using 'qmake -projects':
regarding ".exactMatch" deprecated in Qt6 so i added #include QRegExp in mainwindow.h
Try
[ maybe the proper solution is to build this book example in Qt5 instead of trying to adapt it to build in Qt6 ????]
is that easy to do ???There's nothing wrong with using Qt5 now... however in couple month and years more and more stuff will be deprecated and maybe even removed from Qt Framework.
So why learning outdated things?!
Usually you would follow up-to-date instructions and guides, right?!Most simple Qt5 code can be adapted to Qt6 quite easily even if some methods or modules don't exist anymore... there is never a downgrade (people will argue about that) :D
When porting huge, existing Qt4 / Qt5 projects to Qt6, it's a different story... but for anything else you should be able to find a workaround / replacement. -
@Pl45m4 thanks so much for your frank advice, i'll take it willingly by continuing to pursue Qt6.
your help and support have made a huge difference in the progress that i've been able to have since starting this journey some 3 weeks ago. i very much look forward to mark these posting, solved ! -
".exactMatch" is discontinued in Qt6 so i am trying to use a "wildcard".
is this approach appropriate, that is am i on the right track ?QString wildcard =QRegularExpression::wildcardToRegularExpression("*.jpeg"); if (const auto refs = QStringView{.QStringList = 'wildcard'}.tokenize(u'j')); for (auto wildcard : wildcard) { if (wildcard == '.+\\.(png|bmp|jpg') return true;
-
Why do you insist to use a regexp at all? Simply use QString::endsWith() ...
-
@Pl45m4 said in forgot to setup the environment using 'qmake -projects':
Try
https://doc.qt.io/qt-6/qregularexpression.html#anchoredPattern
I linked this above. It states something like "exact match" in the documentation
-
@Pl45m4
yes i saw and read that previously to my 'wildcard' snippet.
i wasn't getting very far with that but it did lead me into an example using 'QStringList'
i will continue to reading, to get better at understanding the syntax shown in the Qt6 documents.
just wanted to give you an update as to what rabbit-hole i am currently traveling through.@Christian-Ehrlicher
i am not insisting on anything 'regexp' , because i don't know anything as a beginner.
i guess i would have to say that my approach is 'solution via experimentation' .
thank you for "QString::endsWith() " i am looking that up now. -
Success !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
QStringList fileNames;
if (dialog.exec()) {
fileNames = dialog.selectedFiles();
// ".exactMatch" is discontinued in Qt6 so i am using @Christian-Ehrlicher suggestion ".
QStringList str = fileNames;
if (str.endsWith(".jpeg")){
return;
}
i don't want to break this now working windows program but, if i wanted to test for 'bmp' and 'png' file extensions
would it look something like:
if (str.endsWith(".jpeg"||".bmp"||".png"))thanks to @SGaist @Pl45m4 @Christian-Ehrlicher for all the this help and to forum readers who didn't make snide remaks.
-
-
You would either have multiple or statements using endsWith or use QRegularExpression.