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. function returns a struct
QtWS25 Last Chance

function returns a struct

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 262 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.
  • V Offline
    V Offline
    viniltc
    wrote on last edited by
    #1

    Hi all,

    I have a function which returns a struct:

    So I initialized this in the .h file:

    struct Model { QVector<int> values; };
    Model getModelFromFile(QString path);
    

    the fucntion defintion as:

     Model MainWindow::getModelFromFile(QString path) {
        
        Model ret;
    
       ... 
    
        return ret;
    }
    
    

    this gives me error:

    mainwindow.cpp:36:2: error: unknown type name 'Model'; did you mean 'MainWindow::Model'?
    mainwindow.h:21:16: note: 'MainWindow::Model' declared here
    

    someone help me to find issue here?

    sierdzioS 1 Reply Last reply
    0
    • V viniltc

      Hi all,

      I have a function which returns a struct:

      So I initialized this in the .h file:

      struct Model { QVector<int> values; };
      Model getModelFromFile(QString path);
      

      the fucntion defintion as:

       Model MainWindow::getModelFromFile(QString path) {
          
          Model ret;
      
         ... 
      
          return ret;
      }
      
      

      this gives me error:

      mainwindow.cpp:36:2: error: unknown type name 'Model'; did you mean 'MainWindow::Model'?
      mainwindow.h:21:16: note: 'MainWindow::Model' declared here
      

      someone help me to find issue here?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @viniltc said in function returns a struct:

      Model MainWindow::getModelFromFile(QString path) {

      Should be:

      MainWindow::Model MainWindow::getModelFromFile(QString path) {
      

      (Z(:^

      1 Reply Last reply
      4
      • V Offline
        V Offline
        viniltc
        wrote on last edited by
        #3

        @sierdzio Thanks a lot :)

        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