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. Simple table for a settings class
QtWS25 Last Chance

Simple table for a settings class

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 2.8k Views
  • 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.
  • S Offline
    S Offline
    SavageTwinky
    wrote on 26 Jul 2013, 19:46 last edited by
    #1

    So i generally don't use the GUI much with qt, so i'm flat out confused with all the options. Basically all i need is a settings class to complete my little app.

    there are tables, columns and all sorts of fun stuff. I'm not sure the easiest route to what i need.
    All i need is two columns, the first column is locked to a label, the setting column is a editable short. Each row is a different setting.

    I'm looking at some settingseditor example and its not the simplest thing i've seen before... its difficult to break down the actual QTableView part of it.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Jul 2013, 19:52 last edited by
      #2

      Hi,

      It all depends of the type of the settings, you could use a "QFormLayout":http://qt-project.org/doc/qt-4.8/qformlayout.html or "QGroupBox":http://qt-project.org/doc/qt-4.8/qgroupbox.html

      Or associate a "QListWidget":http://qt-project.org/doc/qt-4.8/qlistwidget.html with a "QStackedWidget":http://qt-project.org/doc/qt-4.8/qstackedwidget.html

      You'd have to tell a bit more of your needs or give an example of how you would like it to look

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SavageTwinky
        wrote on 26 Jul 2013, 20:12 last edited by
        #3

        it can look this simple

        | label | value |
        | label | value |
        | label | value |

        label is not editable, value is but has bounds because its a short
        and it can be this simple to set up

        @
        s = new setting()

        foreach(QHash<QString,short> pair, settingsList)
        {
        s.addSetting(pair.key(),pair.value());
        }
        @

        and maybe one signal
        signal settingChanged(QString name, short val);

        we are limited by hardware this is why there are shorts, and it doesn't need to be pretty. I think there are too many options to make this easy for once.

        edit: the only real requirement here is not to back the amount of settings we can use, or bake in any names into the gui. So as my list of settings grow i don't have to worry about this other than maybe sticking in a scroll bar

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Jul 2013, 22:01 last edited by
          #4

          Then a QWidget with a QFormLayout using QSpinBox's limited to the range of short. For the possible scroll bar have a look at QScrollArea and you should be good to go

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SavageTwinky
            wrote on 26 Jul 2013, 22:05 last edited by
            #5

            success! well almost, once i saw you mention QListWidget, i just made a table entry widget with a lineedit thats read only and a spin box.

            add them to listwidget for great success. Only i can't get my list widget to resize at all.

            @
            QListWidget *listWidget = new QListWidget(this);
            listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

            std::list<Setting> list = settings.listSettings();
            foreach(Setting set, list)
            {
                QString entryName = set.c_str();
                short val = settings.getSetting(set);
                SettingsEntry *e = new SettingsEntry(entryName, val);
            
                connect(e, SIGNAL(changed(QString,short)),
                        this, SLOT(onSettingsChange(QString,short)));
            
                QListWidgetItem *i = new QListWidgetItem();
                listWidget->addItem(i);
                listWidget->setItemWidget(i,e);
            }
            

            @

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 26 Jul 2013, 22:08 last edited by
              #6

              Aren't you forgetting to listWidget in a layout ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SavageTwinky
                wrote on 26 Jul 2013, 22:10 last edited by
                #7

                ok that was pretty stupid, the listwidget is useless now, adding a layout....

                edit: wrong again, no scroll bar without the listWidget,, adding to layout..

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SavageTwinky
                  wrote on 26 Jul 2013, 22:28 last edited by
                  #8

                  huh now that it works it looks kind of shitty theres a lot of space inbetween all my options

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 27 Jul 2013, 19:47 last edited by
                    #9

                    You can take a look at the style sheet chapter to modify the aspect of your widget.

                    Or create a QStyledItemDelegate to modify the presentation

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SavageTwinky
                      wrote on 27 Jul 2013, 22:53 last edited by
                      #10

                      i think the style delegate may be a bit too much, i've found that I can change teh border and change the space between. Great an all but I seem to be missing a vertical scroll bar using this method.

                      Using a listwidget works better as its has more things set up but causes overlapping with my widgets...

                      oh well i'll just have to keep reading and messing with settings

                      1 Reply Last reply
                      0

                      1/10

                      26 Jul 2013, 19:46

                      • Login

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