Results 1 to 6 of 6

Thread: using the parent-pointer

  1. #1
    Join Date
    Aug 2007
    Location
    Gothenburg, Sweden
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default using the parent-pointer

    Hello.
    This is probably more a C++ question than a pure QT, but anyway...

    What I want is simply to adress a QObject, lets say the textEdit of the parent widget.
    I want to get some respons from the server which is not connected to the Ui in any other way. I've looked in my c++-books for parent and parent-calls, but haven't found anything...

    I eather get a:
    server.cpp:15: error: insufficient contextual information to determine type
    if i try to user parent.
    or if I try to user the parent->
    it tells me that its not a pointer type.

    Qt Code:
    1. #include "server.h"
    2. #include "client.h"
    3.  
    4. Server::Server(QObject *parent)
    5. : QTcpServer(parent)
    6. {
    7. }
    8.  
    9. void Server::incomingConnection(int socketId)
    10. {
    11. //here I want some kind of parent call...
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 30th August 2007 at 19:49. Reason: changed [qtclass] to [code]

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using the parent-pointer

    You can access the parent of a QObject very simple via QObject:arent(). It returns a QObject.

    Regards

  3. #3
    Join Date
    Aug 2007
    Location
    Gothenburg, Sweden
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using the parent-pointer

    OK. I'll try that. I Like the Smiley there.

    Thanks!

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using the parent-pointer

    Probably there is a lousy text parser that doesn't know it shouldn't add smileys in inside Qt classes names.

    Regards

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: using the parent-pointer

    Quote Originally Posted by marcel View Post
    Probably there is a lousy text parser that doesn't know it shouldn't add smileys in inside Qt classes names.

    Regards
    I complained against this sometime before and the forum admins fixed this while parsing text in CODE block. But they haven't fixed it for all cases yet
    A better fix may be to convert text to smiley only if the text corresponding to smiley is whitespace separated.

    Sorry for being offtopic.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using the parent-pointer

    Well, apparently it knows to parse entities in the form "ClassName::method()" because the links to Qt classes work. maybe because they are contained within QTCLASS -- /QTCLASS tags.

    It shouldn't parse what is between code -- /code tags at all.

    Regards

Similar Threads

  1. Problem with Parent QWidget and Buttons not working
    By VireX in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2007, 22:24
  2. Convert Windows "HWND" to QWidget* pointer?
    By gerome69 in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2006, 13:03
  3. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:00
  4. Referencing Parent Widget from Child
    By taylor34 in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2006, 15:13
  5. get Parent Pointer
    By raphaelf in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2006, 13:09

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.