Results 1 to 4 of 4

Thread: How to pass a Qwidget to a function into a children class ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    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: How to pass a Qwidget to a function into a children class ?

    Quote Originally Posted by tonnot View Post
    1.- How I must to pass the label or Qtextedit to the function ?
    Using pointers ? Can anyone give some easy code ?
    Pass the widgets by pointer. You cannot pass them by value, even if that made sense, because they do not have the requisite copy constructor.
    Qt Code:
    1. class MyClass {
    2. ...
    3. private:
    4. QWidget *aWidget;
    5. };
    6.  
    7. MyClass::record(QWidget *widget)
    8. {
    9. aWidget = widget;
    10. }
    To copy to clipboard, switch view to plain text mode 
    2.- How can I identify what kind of Qwidget is 'A_widget_to_remember'
    QObject qobject_cast to the relevant type and check the returned pointer.

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

    tonnot (9th February 2011)

Similar Threads

  1. Replies: 13
    Last Post: 30th November 2010, 12:47
  2. Replies: 2
    Last Post: 30th September 2010, 09:57
  3. Replies: 14
    Last Post: 1st December 2009, 20:45
  4. How to pass a QComboBox to a function?
    By Ricardo_arg in forum General Programming
    Replies: 4
    Last Post: 9th March 2008, 22:16
  5. How to pass a QString to another class ?
    By probine in forum Qt Programming
    Replies: 9
    Last Post: 9th December 2006, 20:16

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.