Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]How to show same settings for each option in listview?
Forum Updated to NodeBB v4.3 + New Features

[Solved]How to show same settings for each option in listview?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashokb
    wrote on last edited by
    #1

    Hi,
    I am using qt5.1 and developing a GUI. In my mainwindow.ui i have inserted a list view, where some options for user going to display. Now for each option in list view, the same config settings i want to display. But the data related to each options should remain separate, i don't know which is the best way to do it. I thought about tab widget (switching tab for each option) but the number of options are going to change so i cant predesign tabs. And i want to design GUI in mainwindow.ui file not in mainwindow.cpp using those Qtabwidget, QListview etc. classes. Any suggestions please.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      I suggest to use a Model that store all settings for each option

      On the left side of Form you could use a ListView with all options available. On the center of Form you design widgets needed to show all settings.
      When you change selection on ListView, you select the right ModelIndex and show the related settings

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ashokb
        wrote on last edited by
        #3

        Thanks mcosta --For replay, I did as you suggested.
        I want to show my window here, but i don't know how to paste *.png here.
        Anyway, I have a QsqlTableModel, in which all settings are stored. For one option in list view there is one row in model. Now i want to show the values of selected row at different places e.g. first value of selected row in myLineEdit1, second in myLineEdit2 etc. so that user can edit them. And then when he will click on "save" button, i will just do
        @model.submitAll()@

        and model will get updated in database.
        In short is it possible to show single-single entry's of model at different line edits and then directly save model in db?
        Thanks again.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Yes, you can.

          You can use the class "QDataWidgetMapper":http://qt-project.org/doc/qt-5/QDataWidgetMapper.html that allows you to map each field of a Model to a widget

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ashokb
            wrote on last edited by
            #5

            Cheers...
            Thank you mcosta. QDataWidgetMapper is doing great job for me.
            Thank you.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved