Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to access the 3rd element (ComponentWidth) in QList (solved)
Forum Update on Monday, May 27th 2025

How to access the 3rd element (ComponentWidth) in QList (solved)

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 408 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by houmingc
    #1

    How to access the 3rd element (ComponentWidth) in QList

        QList<CComponent>* ComponentList = new QList<CComponent>();
        CComponent ComponentTemplate;
        while (xmlGet.findNextAndDescend("Component"))
        {
    
            QString ComponentID = xmlGet.getAttributeString("ID","unknown");
            QString ComponentType = xmlGet.getAttributeString("Type","unknown");
            int ComponentX = xmlGet.getAttributeInt("X");
            int ComponentY = xmlGet.getAttributeInt("Y");
            int ComponentWidth = xmlGet.getAttributeInt("Width");
            int ComponentHeight = xmlGet.getAttributeInt("Height");
            int ComponentZOrder = xmlGet.getAttributeInt("ZOrder");
            int ComponentAspectRatio = xmlGet.getAttributeInt("AspectRatio");
    
            ComponentTemplate.SetComponentID(ComponentID);
            ComponentTemplate.SetComponentType(ComponentType);
            ComponentTemplate.SetComponentX(ComponentX);
            ComponentTemplate.SetComponentY(ComponentY);
            ComponentTemplate.SetComponentWidth(ComponentWidth);
            ComponentTemplate.SetComponentHeight(ComponentHeight);
            ComponentTemplate.SetComponentZOrder(ComponentZOrder);
            ComponentTemplate.SetComponentAspectRatio(ComponentAspectRatio);
     
                  if (xmlGet.findNext("Background"))
                  {
                      int Transparent = xmlGet.getAttributeInt("Transparent");
                      int Red = xmlGet.getAttributeInt("Red");
                      int Green = xmlGet.getAttributeInt("Green");
                      int Blue = xmlGet.getAttributeInt("Blue");
    
                      ComponentTemplate.SetComponentBackgroundTransparent(Transparent);
                      ComponentTemplate.SetComponentBackgroundRed(Red);
                      ComponentTemplate.SetComponentBackgroundGreen(Green);
                      ComponentTemplate.SetComponentBackgroundBlue(Blue);
     
                  }
                 xmlGet.rise();
                 ComponentList->push_back(ComponentTemplate); //how access 3rd element
     
        }
    1 Reply Last reply
    0
    • H Offline
      H Offline
      houmingc
      wrote on last edited by
      #2

      qDebug()<<ComponentList->at(2).GetComponentAspectRatio();

      found the answer. It is tiring learning Qt API ...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved