Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Basic QVector application
Qt 6.11 is out! See what's new in the release blog

Basic QVector application

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 567 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Uberlinc
    wrote on last edited by
    #1

    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:

    9dcbf27e-48a8-47be-9a86-d7e660f2a0b1-image.png

    8ae25a69-e9d9-43db-a96e-65e0125466d1-image.png

    Thanks in advance.

    JonBJ 1 Reply Last reply
    0
    • U Uberlinc

      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:

      9dcbf27e-48a8-47be-9a86-d7e660f2a0b1-image.png

      8ae25a69-e9d9-43db-a96e-65e0125466d1-image.png

      Thanks in advance.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Uberlinc
      This has nothing to do with QVectors, or widgets. It's basic C++.

      At line #28MainWindow::listVector is a reference to a static member of MainWindow, which is not what you have. You need to take whatever your instance of MainWindow is, e.g. perhaps you have a MainWindow mainWindow = new MainWindow(...), and reference mainWindow->listVector.

      At line #35, there is no listVector to reference. You mean to either reference mainWindow->listVector, or void printVector is intended to be a member method of class MainWindow. Similarly for the ui.

      Forget about vectors for a while. Sort out your class/member/instance references.

      1 Reply Last reply
      5
      • U Offline
        U Offline
        Uberlinc
        wrote on last edited by
        #3

        Okay, thanks..
        I'm a bit rusty at both but trying to put it all together.

        mrjjM 1 Reply Last reply
        0
        • U Uberlinc

          Okay, thanks..
          I'm a bit rusty at both but trying to put it all together.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Uberlinc

          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 :)

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved