Results 1 to 3 of 3

Thread: Parents of (Tab)Widgets when using Eclipse QT Plugin

  1. #1
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Parents of (Tab)Widgets when using Eclipse QT Plugin

    I'm very new to QT, but used to Eclipse, so I love the Eclipse QT Plugin, but now here is something I don't understand and I was hoping you could help me:

    My understanding of the plugin so far is, that I click together my gui, which is saved in an XML file (say: myprog.xml) and by some higher magic transformed into C++ code (ui_myprog.h) that describes where to put the elements and what to do with them.

    I have a simple application containing a QTabWidget that has 2 tabs, containing my own Widgets called InputTab and PreprocessingTab. When I look in the automatically created ui_myprog.h, it creates this QTabWidget like this:

    Qt Code:
    1. tabWidget = new QTabWidget(SmyrnaClass);
    2. tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
    3. tabWidget->setGeometry(QRect(0, 0, 1011, 781));
    4. tabWidget->setTabPosition(QTabWidget::West);
    5. tabWidget->setTabShape(QTabWidget::Rounded);
    6. inputTab = new InputTab();
    7. inputTab->setObjectName(QString::fromUtf8("inputTab"));
    8. tabWidget->addTab(inputTab, QString());
    9. preprocessingTab = new PreprocessingTab();
    10. preprocessingTab->setObjectName(QString::fromUtf8("preprocessingTab"));
    11. tabWidget->addTab(preprocessingTab, QString());
    To copy to clipboard, switch view to plain text mode 

    My own class for InputTab has a predefined constructor like this:

    Qt Code:
    1. InputTab(QWidget *parent = 0);
    To copy to clipboard, switch view to plain text mode 

    and I found out that it is indeed constructed without a parent. However, later in other methods of InputTab I am able to access its parent (the QTabWidget) and its grandparent (MyProg). However, I don't see where the parent was set. This should be done in ui_myprog.h, but I see nothing like this. I observed this problem when I was trying to access the parent in the constructor, where it is still undefined. Now I wonder what I have to do to make sure the parent really is set. Would be great if someone could help me out :-/

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Parents of (Tab)Widgets when using Eclipse QT Plugin

    Qt Code:
    1. tabWidget->addTab(inputTab, QString());
    2. tabWidget->addTab(preprocessingTab, QString());
    To copy to clipboard, switch view to plain text mode 
    When you insert the widget into a QTabWidget, QTabWidget takes ownership (becomes parent) of the widget (which is inputTab/preprocessingTab in your case)

  3. The following user says thank you to Santosh Reddy for this useful post:

    chrisQL (7th June 2011)

  4. #3
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parents of (Tab)Widgets when using Eclipse QT Plugin

    Ah, that explains a lot ... thank you!!

Similar Threads

  1. wwWidgets and Qwt plugin for eclipse?
    By sdhengsoft in forum Installation and Deployment
    Replies: 1
    Last Post: 7th April 2011, 11:01
  2. Semi-transparency through parents' widgets
    By Anatoly in forum Qt Programming
    Replies: 2
    Last Post: 21st December 2009, 09:23
  3. How can i add a qwt5 plugin to eclipse integration?
    By remnant24c@nate.com in forum Qwt
    Replies: 0
    Last Post: 25th September 2009, 02:06
  4. Replies: 2
    Last Post: 26th June 2008, 04:46
  5. using Qt plugin for Eclipse
    By high_flyer in forum General Discussion
    Replies: 1
    Last Post: 28th September 2006, 06:26

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.