forgot to setup the environment using 'qmake -projects'
-
@Pl45m4 > So how did you install Qt?
i used this site: https://www.qt.io/download-open-source
and downloaded the Qt Online Installer
qt-creator-opensource-linux-x86_64-14.0.1.run@Pl45m4 thanks for the help.
"messed up" is an understatement
i am unable to get past page 12 in the book, so OpenCV is even mentioned in this book yet.the 'qt6_design_studio_reduced_version'
i think??? comes from the installation's default install options.(this was when i was trying to use Windows11 last week and could not get the example to work so...because the book's author was using Linux in his example, i decided to try that, using WSL- Ubuntu)
i do not know what should be chosen in a fresh install to meet the book's author statement: "GCC5 or later on Linux".
-
update: thank you @Pl45m4 because of your suggestion of "create a new project in QtCreator via the project wizard"
was awesome, as i did not know about that and it allowed me to use it as a 'template' for the book example !
that book example was created by the author using Qt5 and i am trying to use Qt6.
so even though i modified the 'template' by replacing the 4 book example files, Qt6 generated a few errors that i was able to fix
except this one which is beyond my skills to correct.
so i think if someone can help resolve "QRegExp" has not been declared", the program might build w/o further compile errors.
it is the 2nd "QRegExp" in line 149 that the 'Complie Output' screen flags.question: why is the 1st occurrence of "QRegExp" not flagged as undeclared but the 2nd one is ???
....\mainwindow.cpp: In member function 'void MainWindow::nextImage()':
....\mainwindow.cpp:149:33: error: 'QRegExp' was not declared in this scope
//line 149 | int idx = fileNames.indexOf(QRegExp(QRegExp::escape(current.fileName())));file: mainwindow.cpp [snippet relavant to error]
void MainWindow::prevImage()
{
QFileInfo current(currentImagePath);
QDir dir = current.absoluteDir();
QStringList nameFilters;
nameFilters << ".png" << ".bmp" << "*.jpg";
QStringList fileNames = dir.entryList(nameFilters, QDir::Files, QDir::Name);
line149 int idx = fileNames.indexOf(QRegExp(QRegExp::escape(current.fileName())));
if(idx > 0) {
showImage(dir.absoluteFilePath(fileNames.at(idx - 1)));
} else {
QMessageBox::information(this, "Information", "Current image is the first one.");
}
} -
@uglybug said in forgot to setup the environment using 'qmake -projects':
QRegExp" has not been declared"
QRegEx
got removed from Qt6 and is now in a Qt5-Qt6 compatibility module.
UseQRegularExpression
instead. (#include <QRegularExpression>
) -
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.