Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to use Scroll Area in Qt to print a QString array
jefazo92 last edited by jefazo92
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.
for(int i = 0: i < TABLESIZE; i++)
JonB last edited by JonB
Hi there. In the politest way, I'm afraid what you write/ask does not make much sense! You need to do some reading/playing to get the hang of Qt widgets.
QScrollAreais just a container, for other widgets, which happens to have a fixed size and allows scrolling via scrollbars if its content exceeds its size.
Basically, what you probably mean you want to do for your example is create widgets --- like
QTextEdit--- for each of the texts of your data fields, and then add those widgets onto a
QScrollArea(probably inside some kind of
Having said that, you might find that using, say, a
QTableWidgetwhose model is your data, is what you really want. That will lay out your data in rows & columns. If that table itself can get too high or wide to fit, you would enclose the table inside a
QScrollAreaand scroll the table as a whole up/down/right/left.
jefazo92 last edited by
Hi @JonB JonB, just saw your other message. Don't know what happened there. I only posted once.
JonB last edited by
OK. Like I said, forget about scrolling for now. You need to get the hang of just adding what Qt calls "widgets" to display your data.
Since you have a loop for rows and then various columns in each row, a
QTableWidgetwould be the first thought for presentation. Rather than talking about "commas" & "lines".