Help with setting QTableView's vertical header data
-
[quote author="SGaist" date="1366987686"]With your last query you will only get one column with the channel names.
How does your database look like ?
A table with the channels and a table with the shows and their time ?[/quote]Yes, I will get only one column with the channel name which I want to display as the vertical headers.
Within the loop where I get the channel names, I use another SQL query to get all the show titles and timings for that particular channel which is active in the current loop.
For example, if my channels are HBO, Fox and CBS, I run a loop while query.next() to get each channel. Inside this loop, when HBO is my current channel query.value(0), I use the channel name to get the show titles and then display them. Since the loop will run thrice, I get all the show titles for all three channels one after the other.
-
Then... Why do you use a QTableView with a QSqlQueryModel ? You won't get all shows data since you change the query on each loop
-
OMG! I'm so sorry. I'm confusing you and myself here. When I couldn't set the QTableView's vertical header, I moved on to generating the grid using just QLabels and that's when I used the looping technique. I'm so so sorry for the confusion.
With QSqlQueryModel, i simply used a single query to get the show details. However, I couldn't display the channel details as the vertical header which is why I posted this question originally.
Once again, I'm really very sorry :( -
If you are now running the query for each channel individually and pulling the data. You could simply use a QTableWidget and make the grid as you wanted before.
-
I could. But there's another problem. Please have a look at "this question":http://qt-project.org/forums/viewthread/27263/ I posted.
What I actually have to do is this:@
| Label1 | Label2 | Label3 | Label4 |
| Label5 | Label6 | Label7 | Label8 |
| Label9 | Label10 | Label11 | Label12 |
@
So I not only have to generate these labels on the GUI, but also access them using indices so I can manipulate their properties like
@
label [0][2]->setText("Changed label");
@I'm struggling to find the right data structure to use to solve my issue. Please please help.
-
Hi again!
I couldn't solve my problem using _QTableWidget_ or similar widgets so I used a different "approach":http://qt-project.org/forums/viewthread/27263/ instead. I'd love to learn new ways of solving the same problem though :)
-
Ok I see now...
With layout you need, you would have to make your own QAbstractItemView on top of your model
-
Oh ok. I'll try implementing that too and see which one suits better. Thanks very much for your assistance SGaist. You've been very kind and patient :)
-
You're welcome !
IIRC there are some good examples in the book Advanced Qt Programming that might help
-
By Mark Summerfield right? I have that book. I read the first few pages and then I got too lazy to continue. I learned so much more from "Void Realms":http://www.youtube.com/playlist?list=PL2D1942A4688E9D63, "Bucky":http://www.youtube.com/course?list=ECD0D54219E5F2544D, online Qt "documentation":http://qt-project.org/doc/qt-4.8/ and of course the most awesome forum on web, qt-project.org :)
But I guess I could give the book another try!