How to use Scroll Area in Qt to print a QString array

Hi everyone,

I am trying to understand how to use "Scroll Area" in "Containers" of Qt when designing GUIs. In my case, I have a display function which displays the data from a hash table of objects into the scroll area. Each element of the object stored at the specified index of the array is of type QString and will be printed onto the area separated by a comma and would also need to make it so that once the last element of the object (phone) is returned, the next object is printed onto the next line. I have taken a look at the documentation but haven't found anything of use for what I'm looking. I am not looking to create a parent or child since I don't understand that concept. Ideally, I would be looking for something of the sorts of ui->scrollAreaContents-> since it is simple to use. I have posted my code for the function below. Thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
 void Database::display(){
      for(int i = 0: i < TABLESIZE; i++)
        {
           table[i]->getName();
           table[i]->getJob();
           table[i]->getVehicle();
           table[i]->getAddress();
           table[i]->getCountry();
           table[I]->getPhone();
  
}  
}
Last edited on
QScrollArea is a "widget", not a "container". I suppose it's kind of a container since it "contains" another widget for which it provides scrolling. But the technical word "container" is best reserved for things like std::vector (and the Qt equivalents, which you probably shouldn't use these days).
Last edited on
Topic archived. No new replies allowed.