Results 1 to 4 of 4

Thread: How to disable individual members of a QHash and QList?

  1. #1
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default How to disable individual members of a QHash and QList?

    In my project i have a widget which have a QHash vector table and QList on it.I want to access each individual members of the QHash and QList and then disable the members.But i don't get any function to disable the members.

    Code:

    Qt Code:
    1. for(index=0;index<screen.children.count;index++)
    2. {
    3.  
    4. screen.children.at(index).?
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    Here screen is a QWidget. In Qwidget class we have a function called setdisabled which can be used to disable the whole widget but how to disable the individual members?
    Last edited by Lykurg; 21st July 2011 at 08:12. Reason: missing [code] tags

  2. #2
    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 disable individual members of a QHash and QList?

    It makes no sense to talk about "disable the members". If you don't want something in the container then either don't add it or QList::removeAt()/QHash::remove() it. QHash and QList are containers that can contain almost anything and have no visible presence, i.e. they cannot be "on" a QWidget.

    Your code snippet also makes little sense. QObject::children() returns a list of QObject pointers, only some of these (if any) will be QWidgets that have any sort of visible presence. To access these as QWidgets through this path you will have to qobject_cast<QWidget*>() and check if the result is not null.

    It really is easier to keep a pointer to the widgets you wish to disable than to try to find them indirectly later.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. #3
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: How to disable individual members of a QHash and QList?

    Ok Chris here is the code snippet.....

    Qt Code:
    1. QAppScreen::QAppScreen(QWidget *parent) : QWidget(parent) {
    2. #ifdef QT_DEBUG_APPLICATION_SCREEN
    3. qDebug() << "QTmApplicationScreen:" << "Create Application Screen";
    4. #endif
    5. setLayout(new QVBoxLayout);
    6. //setLayout(new QHBoxLayout);//Added
    7. m_deviceList = new QHash<int, QWidget *>();
    8. m_iconList = new QList<QAppIcon *>();
    9. }
    10.  
    11.  
    12. void QAppScreen::addApplication(QTmApplication *application,QWidget *mwidget) {
    13. #ifdef QT_DEBUG_APPLICATION_SCREEN
    14. qDebug() << "QTmApplicationScreen:" << "Add Application" << application->name() << "to App List" << application->upnpControlPointId();
    15. #endif
    16. if (!m_deviceList->contains(application->upnpControlPointId())) {
    17. QWidget *widget = new QWidget(this);
    18. widget->setLayout(new QHBoxLayout);
    19. layout()->addWidget(widget);
    20. //layout()->addWidget(mwidget);
    21. m_deviceList->insert(application->upnpControlPointId(), widget);
    22.  
    23. }
    24. QAppIcon *icon = new QAppIcon(application, this);
    25. m_deviceList->value(application->upnpControlPointId())->layout()->addWidget(icon);
    26. m_deviceList->value(application->upnpControlPointId())->layout()->addWidget(mwidget);
    27.  
    28. connect(icon, SIGNAL(clicked(QTmApplication*)), this, SIGNAL(launchApplication(QTmApplication*)));
    29. m_iconList->append(icon);
    30.  
    31. update();
    32. }
    To copy to clipboard, switch view to plain text mode 

    The requirement is i want to disable the icons but not the mwidget.....icons are used to launch certain apps.....and the icons are populating from a server and the above code is runnig in the client....is der any option?
    Last edited by Lykurg; 21st July 2011 at 08:13. Reason: missing [code] tags

  4. #4
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: How to disable individual members of a QHash and QList?

    Anybody???

Similar Threads

  1. Replies: 6
    Last Post: 22nd March 2011, 15:17
  2. QList < QHash < int, QString> > ... clear() is slow
    By JoZCaVaLLo in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2011, 11:07
  3. Replies: 4
    Last Post: 20th August 2010, 13:54
  4. Can QHash::capacity() be smaller than QHash::size()?!?
    By iw2nhl in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2007, 01:17
  5. Query about QHash , QList
    By aamer4yu in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2006, 09:04

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.