Basic QVector application
-
Hi,
Trying to do a basic QVector application to populate a QListWidget.I have successfully populated and printed the contents of a QVector in a console app, but don't quite get it with a QtWidgets application.
Is there something glaringly obvious that I'm doing wrong?
Please see screenshots:
Thanks in advance.
-
@Uberlinc
This has nothing to do withQVector
s, or widgets. It's basic C++.At line #28
MainWindow::listVector
is a reference to a static member ofMainWindow
, which is not what you have. You need to take whatever your instance ofMainWindow
is, e.g. perhaps you have aMainWindow mainWindow = new MainWindow(...)
, and referencemainWindow->listVector
.At line #35, there is no
listVector
to reference. You mean to either referencemainWindow->listVector
, orvoid printVector
is intended to be a member method of classMainWindow
. Similarly for theui
.Forget about vectors for a while. Sort out your class/member/instance references.
-
Hi
in this case
The main issue is that you do include loadvec/printVec as members
but the .cpp code you show you forgot
MainWindow:: in front so compiler thinks they are just global functions.Should be
void MainWindow::loadVector() {
...
}then it works :)