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 question - What am I doing wrong here?
Forum Updated to NodeBB v4.3 + New Features

Basic question - What am I doing wrong here?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 276 Views
  • 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,

    Still got my training wheels on.
    I don't know why it won't recognize the objects listWidget and each of the numerically named ones - they are objects defined within the GUI form.

    The functions printlist() and setNumbers() are both declared in the mainwindow.h.
    For some reason, they work fine if I place the code in the MainWindow constructor, but if I put them into a function and call them, it doesn't recognize them.
    I've tried preceding them with ui-> as well, but then it complains it doesn't recognise 'ui'.

    Any hints?
    Thanks.

    0e218528-bdc3-4050-90fe-e18862205f59-image.png

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      printList(..) & setNumbers(..) are not method of your class MainWindow. Move those methods as class methods. It should work.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

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

        This is how they were declared in MainWindow.h

        71cd26c0-08e2-4e5b-81fe-625179d3059c-image.png

        I don't understand where I should move them to or declare them so that they can be encapsulated in their own function.

        Can you please explain?

        Thanks.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gerd
          wrote on last edited by
          #4

          You need to implement your Methode directly. Just change the Code in your cpp file to
          void```
          void Mainwindow::

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Gerd
            wrote on last edited by
            #5

            You need to implement your Methode correctly. Just change the Code in your cpp file to

            void  Mainwindow::printList 
            And 
            void Mainwindow::setNumbers
            
            1 Reply Last reply
            3
            • U Offline
              U Offline
              Uberlinc
              wrote on last edited by
              #6

              Thank you.
              That worked!

              1 Reply Last reply
              0

              • Login

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