Just wrapped up section 3 of my Qt C++ beginner GUI course! Boy, this course is fun! I really appreciate the instructor taking the time to show 3 different ways to do things, and explaining why one might be more useful than others in different situations. I did run into a couple of errors though:
warning: ‘auto’ changes meaning in C++11; please remove it
And this one, too:
error: no matching function for call to ‘Widget::connect(QPushButton*&, void (QAbstractButton::*)(bool), Widget::Widget(QWidget*)::<lambda()>)’
});
Both of these are related, so I thought I’d bundle them together in this post. Apparently, GCC for Linux, while super smart, is so flexible that you can, of course, use different C++ standards, however, by default, it uses the OLDEST one. WHY?! So, in Qt creator, you have to tell it specifically to use the latest C++ standard, like so:
#-------------------------------------------------## Project created by QtCreator 2018-06-22T09:40:37##-------------------------------------------------QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = section_3_18TEMPLATE = appSOURCES += main.cpp\widget.cppHEADERS += widget.hFORMS += widget.uiQMAKE_CXXFLAGS = -std=c++14QMAKE_LFLAGS = -std=c++14
Those last two QMAKE lines are the ones I added. You can set them to any standard you like that is in your compiler, such as c++11, c++14, c++1z (well, on mine that is the 2017 standard, some newer ones may have c++17). Adding those two lines and saving the file will fix it.
The second error was caused because I had Qt4 and Qt5 installed. Obviously, you should use the newest one available to you. So, I had to click:
Tools->Options->Kits->Desktop
And choose the latest Qt5 version, rather than the default of the lower Qt4 version. It took me a while of web browsing to figure this out, so hopefully this will save someone else some time!
Linux – keep it simple.