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. How to launch a table with columns' names set as checkboxes' labels
Forum Updated to NodeBB v4.3 + New Features

How to launch a table with columns' names set as checkboxes' labels

Scheduled Pinned Locked Moved General and Desktop
23 Posts 4 Posters 6.2k 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.
  • P Offline
    P Offline
    pkjag
    wrote on last edited by
    #1

    Hi all
    So i have a wizard and a mainwindow that launches after the wizard winds up. The mainwindow's central widget is currently disabled so i wanted it to launch a table with columns as soon as the finish button in the last page of the wizard is clicked. The columns to be launched should correspond to the checkboxes in one of the wizard's pages. Like when some of the checkboxes are checked the mainwindow should launch the table with the labels of those checkboxes as the columns' names. I hope you understand because i've tried posting the picture here but it didn't work. Can you guys help??

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      One way you could do this is to add a getter to your wizard that would return a QStringList containing the checkboxes label and use it to create a QTableView which headers are set using that list.

      Hope it helps

      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
      • P Offline
        P Offline
        pkjag
        wrote on last edited by
        #3

        Can this work?
        @
        QStringList list = findChildren<QCheckBox>();

        //then use

        setHeaderLabels(list);

        //as a slot
        @
        Also, can disabled checked checkboxes be tested using isChecked??

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No, it won't even compile. findChildren will return a QList<QCheckBox*> in this case.

          Also, using findChildren like that doesn't go toward clean code. The wizard page containing the checkboxes should handle the QStringList creation since it knows the checkboxes. The wizard could then return the string list generated by the wizard page.

          As for the test, AFAIK yes

          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
          • P Offline
            P Offline
            pkjag
            wrote on last edited by
            #5

            So what function do i use to extract the checkboxes if the wizard page knows them??

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Since you seem to have a fixed number of check boxes, just go trough them in the getter (either by having them as member variables, using findChildren etc..), check what you need about them and construct the string list based on your logic.

              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
              • P Offline
                P Offline
                pkjag
                wrote on last edited by
                #7

                Ok about launching the mainwindow after the wizard winds up i did this:
                @
                int ConclusionPage::nextId() const
                {
                connect(this, SIGNAL(buttonClicked(QWizard::FinishButton)), window, SLOT(LaunchWidget()));
                return -1;
                }
                @
                to my conclusion page that contains the finish button, window is an object pointer to the class MainWindow. LaunchWidget() is a slot that enables the central widget which was previously set to launch a text edit for experimental purposes to see if it would work. LaunchWidget() is defined in the MainWindow and is called right after the constructor.

                But when i compile it returns this error:
                @
                C:\mystuff\maprojo\SkoolCalc\SkoolCalcWizard.cpp:312: error: no matching function for call to 'ConclusionPage::connect(const ConclusionPage* const, const char [38], MainWindow* const&, const char [16]) const'
                @

                is there anything wrong with my implementation apart from the error??

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pkjag
                  wrote on last edited by
                  #8

                  any help anyone??

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Your wizard should not know anything about your MainWindow, that creates a useless tight coupling. You should rather connect the finished signal from your wizard to the LaunchWidget slot in your MainWindow

                    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
                    • P Offline
                      P Offline
                      pkjag
                      wrote on last edited by
                      #10

                      By knowing about the mainwindow object do you mean not declaring it in the wizard header and imlplementation files?? Because AFAIK i have done what you've just written above apart from the wizard not knowing about the window which will need some more elaboration??

                      1 Reply Last reply
                      0
                      • JeroentjehomeJ Offline
                        JeroentjehomeJ Offline
                        Jeroentjehome
                        wrote on last edited by
                        #11

                        What is most common is this:
                        @
                        WizardLoadMapFile LoadMapWizard(this);

                        LoadMapWizard.setFileName(FileName_str);
                        
                        if (LoadMapWizard.exec&#40;&#41; == QDialog::Accepted)
                        {
                          this->m_NewFileName = LoadMapWizard.m_MapFileName;
                          emit signal(m_NewFileName); // Just an example
                        }
                        

                        @
                        Where the WizardLoadMapFile is the QWizard inherited class that contains member variables holding the needed information that the mainWindow needs to construct the table (or something else)

                        Greetz, Jeroen

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          pkjag
                          wrote on last edited by
                          #12

                          What about just launching the mainwindow with a textedit central widget just after the wizard button finish is clicked in the conclusion page. My mainwindow is set to launch a textedit for now for experimental purposes which is currently disabled, but i want to launch it once the conclusion page winds up??

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            pkjag
                            wrote on last edited by
                            #13

                            Hello anyone??

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              andre
                              wrote on last edited by
                              #14

                              [quote author="pkjag" date="1380273224"]Hello anyone??[/quote]

                              Practice some patiece please.

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                pkjag
                                wrote on last edited by
                                #15

                                Hey Andre can you help me with this problem??
                                I've been going through it a lot and i'm kinda stuck!!

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  andre
                                  wrote on last edited by
                                  #16

                                  To me, it is no so clear anymore what your actual problem is at the moment. SGaist gave you some valuable suggestions already. What did you do with those?

                                  However, I doubt a stringlist is the best data structure for this purpose. What would be in the strings exactly? I guess you don't have an endless variety of columns you can display and populate. One the one hand it is inefficient to use strings to contain static names for columns, and on the other is is not a good idea to use translatable strings for application logic. So, if your set of possible columns is indeed limited, I'd simply make an enum for them and use a QFlags (or as QVector<ColumnEnum> if ordering is important) to communicate the columns to display.

                                  1 Reply Last reply
                                  0
                                  • P Offline
                                    P Offline
                                    pkjag
                                    wrote on last edited by
                                    #17

                                    That's sorted out. My problem now is launching the table in the mainwindow's central widget(it's currently set to disabled) immediately the finish button is clicked in the conclusion page of the wizard. The code above shows my attempt, but it apparently doesn't work!!

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      pkjag
                                      wrote on last edited by
                                      #18

                                      is anybody gonna answer this?

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #19

                                        It doesn't and it's not the best design either.

                                        Did you try the suggestion of Jeroentj@home ?

                                        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
                                        • P Offline
                                          P Offline
                                          pkjag
                                          wrote on last edited by
                                          #20

                                          That's for collecting the checkboxes information about being clicked, what about for launching the actual table for experimental purposes say without the columns in the mainwindow, that's the main problem!

                                          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