Results 1 to 5 of 5

Thread: Using function from another class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using function from another class

    Hey waynew!
    Could I possibly take a sneek peek at your code?
    The problem is that I've derived my code from the examples. Unfortunately, there is no example that implements both the sending and receiving ability of the class and the sreader (creates a slot that is activated when data is received) is mostly implemented in a .h file.
    I use the sreader.h (located in the examples folder) as is with the exception of the ReadOnly changed to ReadWrite.
    What I then try to do is to reach the QSerialDevice that is defined in sreader.h from the mainwindow.cpp. This is a standard GUI application with a mainwindow with a button connected to the slot (sendButtonClickHandler). When this buttn is clicked I want to send The Character "A" on the bus. This code works in the example "writer" but in that file "MyDevice" is defined in the same file...
    The code looks like this:

    Qt Code:
    1. void MainWindow::sendButtonClickHandler()
    2. {
    3. QByteArray ba("A"); //data to send
    4. qint64 bw = 0; //bytes really writed
    5. //bw = 0;
    6. bw = MyDevice->write(ba);
    7. std::cout << bw;
    8. }
    To copy to clipboard, switch view to plain text mode 

    As I said earlier when I try using Reader::MyDevice it says that Reader is not a class...

    Cheers!
    /Tottish
    Last edited by Tottish; 8th April 2010 at 08:33. Reason: added code

Similar Threads

  1. QtConncurrent - calling function within the class
    By jacek_ in forum Qt Programming
    Replies: 5
    Last Post: 28th October 2009, 17:37
  2. Problem with the put() function of QFtp class
    By whyisosad in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 10:03
  3. Replies: 3
    Last Post: 16th May 2007, 11:07
  4. function 'connect' always look super class for slots.
    By Intaek Lim in forum Qt Programming
    Replies: 7
    Last Post: 12th March 2007, 13:38
  5. Problems calling C function in C++/Qt class
    By Rayven in forum General Programming
    Replies: 2
    Last Post: 2nd June 2006, 21:32

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.