Important: Please read the Qt Code of Conduct -

Hi evryone. 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.

    void Database::display(){
    for(int i = 0: i < TABLESIZE; i++)


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    From the looks of it, you should rather take a at the Model View chapter of QT's documentation.

    That will allow you to do what you want in a more automated fashion.

  • @dangquan09
    How come this is character-for-character the same question as posed by @jefazo92 last week in ? I answered it there. Are you a different person who types in the same as the other user, or did you choose to ignore the answer there?

Log in to reply