Results 1 to 20 of 31

Thread: Transfer of a QByteArray to main.cpp

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Transfer of a QByteArray to main.cpp

    This line of main.cpp:
    Qt Code:
    1. mainWidget w(const QUrl &Urlh);
    To copy to clipboard, switch view to plain text mode 
    is not what you think it is. This is a declaration of a function w() that takes a QUrl and returns a mainWidget (that function does not exist). What you are trying to do is construct a mainWidget object and provide its constructor with an argument (a QUrl value) thus:
    Qt Code:
    1. mainWidget w(histUrl);
    2. w.show();
    To copy to clipboard, switch view to plain text mode 
    This is precisely the same sort of thing you do in the mainWidget constructor when you pass the QUrl value into the FileDownloader constructor.

    What is at line 22 of filedownloader.h?

    Edit: Answered my own question

    Line 22 of filedownloader.h must be this one:
    Qt Code:
    1. void DataA(m_DownloadedData);
    To copy to clipboard, switch view to plain text mode 
    The header is a declaration not an implementation. You are declaring a function DataA(...) that returns nothing and takes an argument. The stuff in the parentheses is the type (and optionally name) of the argument. What you have supplied is a name that is unknown as a type: hence the error. What you should be doing is:
    Qt Code:
    1. void DataA(const QByteArray &someName);
    To copy to clipboard, switch view to plain text mode 
    While this is a Qt signal, to C++ it is simply another function. The implementation of this function is provided by the Qt tools (moc), which is why you do not need/see this function implemented in filedownloader.cpp.


    It seems that a lack of understanding of C++, not Qt, is a reasonable part of the problems here. Rather than run up a white flag perhaps taking a step back and doing some generic C++ tutorials would be useful.
    Last edited by ChrisW67; 18th January 2015 at 02:32. Reason: updated contents

  2. The following user says thank you to ChrisW67 for this useful post:

    dolin93 (21st January 2015)

Similar Threads

  1. Replies: 2
    Last Post: 8th August 2014, 19:08
  2. Replies: 6
    Last Post: 14th May 2014, 12:14
  3. Replies: 1
    Last Post: 22nd June 2011, 08:12
  4. Replies: 9
    Last Post: 25th July 2009, 13:27
  5. Replies: 11
    Last Post: 11th August 2008, 09:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.