Results 1 to 5 of 5

Thread: access the widget dynamically

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: access the widget dynamically

    there are several ways... but if i understood correctly.. on creation of buttons you can use a QHash

    QHash<QString, QPushButton*> hash;
    QString name = getNameFromSomeWhere();
    QPushButton * btn = new QPushButton(name,this);
    hash.insert(name,btn);

    and so on

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

    mohanakrishnan (26th November 2009)

  3. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: access the widget dynamically

    Or you can use QObject::findChild():
    Qt Code:
    1. QPushButton *button = parentWidget->findChild<QPushButton *>("button1");
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to Lykurg for this useful post:

    mohanakrishnan (26th November 2009)

  5. #3
    Join Date
    Oct 2009
    Location
    chennai,india
    Posts
    66
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: access the widget dynamically

    hi Lykurg
    thanks a lot it worked well.
    thanksss

    qtcentre is great

  6. #4
    Join Date
    Oct 2009
    Location
    chennai,india
    Posts
    66
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: access the widget dynamically

    hi mrdeath
    i ll try wat u said ,and then come back..
    thanks a lot

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Access the subTab Widget in Main TabWidget
    By hasnatzaidi in forum Newbie
    Replies: 1
    Last Post: 2nd September 2009, 08:21
  3. Creating dock widget as tab dynamically
    By vidyadhar in forum Qt Programming
    Replies: 1
    Last Post: 18th July 2009, 12:03
  4. Replies: 5
    Last Post: 17th June 2009, 14:01
  5. Replies: 8
    Last Post: 20th September 2007, 09:10

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.