Qt World Summit: Register Today!

Basic question - What am I doing wrong here?

  • 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?


  • Qt Champions 2017

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

  • This is how they were declared in MainWindow.h


    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?


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

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

    void  Mainwindow::printList 
    void Mainwindow::setNumbers

  • Thank you.
    That worked!

Log in to reply