Displaying database values with radio button selection?
-
Thanks a lot qxoz for your reply, I want to show Email_Id values recursively in that window with radio button besides it, when Administrator selects one and clicks on Next> he would get all information of that particular Email_Id in the next window containing respective form fields.
Here is the sample Table:
Email_Id | First Name | Last Name | Contact Number | Gender
joe@doe.com | Joe | Joey | 12345 | M
doe@joe.com | Doe | Doey | 67891 | MThank you Mr. Andre, I dont know about QDataWidgetMapper, will study about it now...
-
Right solution would be creating your "own model":http://doc.qt.digia.com/4.7-snapshot/modelview.html for representing data and "own delegate":http://doc.qt.digia.com/stable/itemviews-spinboxdelegate.html for displaying radiobutton. But if you want use QTableWidget you can set widget for a cell by setIndexWidget().
-
Yeah Mr.Andre, that's perfectly guessed though not a table whole together but just the primary key values with radio buttons for each of the value (its Email_Id in my case), so when Admin selects this one radio button value, and clicks on submit button, the next window must be populated with form fields displaying information of that particular Email_Id.
-
Sure, single selection on a normal tree view would be the obvious choice. If you really want, you can however visually represent the selection with a radio button using a proxy model. The proxy model could take the QItemSelectionModel. Depending on if the row is selected, it could give a different result for the Qt::DecorationRole of the first column. Just use two images, one of a checked and one of an unchecked radio button. For bonus points, use the current style to render them :-)
-
Well good question Mr.QXOZ, I will explain the remaining application perspective now:
"Radio button selection is a must, the DB Table contains extra information like what type of gifts they need, because after viewing the information of that particular Email_Id, I would like to create a particular gift box for each and every user based on this information. Gift box just includes some documents and some secrets ;-). And all this packing is included in my Qt App"
-
I'd advise you to leave the whole idea of using radio buttons for the selection alone for now, and just use a table configured to use single row selection. You can always add the visual effect of a radio button later. First get the rest of your application to work before worrying about details like this.
Note that using radio buttons in item views is very non-standard. Checkboxes are used frequently, but radio buttons will look quite alien.