Results 1 to 2 of 2

Thread: QWidget and type

  1. #1
    Join Date
    Jun 2007
    Posts
    28
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWidget and type

    Hi,

    thanks for the big help that I receive here.
    Now I have this problem:
    in a QWidget array, I have more type of widget. For example widget[0] is QDoubleSpinBox, widget[1] is QLineEdit, and widget[2] is QSpinBox.
    Is possible know the type of widget by code?
    I need this because if the widget is QSpinBox I make same operation, if is QLineEdit other operations...

    Thanks,
    Nowire

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWidget and type

    Qt Code:
    1. if (QSpinBox* spinBox = dynamic_cast<QSpinBox*>(list.at(i)))
    2. {
    3. spinBox->doSomething();
    4. }
    5. else if (QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(list.at(i)))
    6. {
    7. lineEdit ->doSomethingElse();
    8. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    nowire75 (8th November 2007)

Similar Threads

  1. Replies: 1
    Last Post: 15th October 2007, 14:21
  2. Delayed Rendering of QTabWidget Tabs
    By mclark in forum Qt Tools
    Replies: 13
    Last Post: 14th May 2007, 22:53
  3. Replies: 4
    Last Post: 24th April 2007, 13:18
  4. how to specify the WFlags in QWidget....
    By sar_van81 in forum Qt Programming
    Replies: 2
    Last Post: 22nd December 2006, 08:35
  5. Cannot queue arguments of type 'QStringList'
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 20:48

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.