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. Some errors in a program I'm developing
Qt 6.11 is out! See what's new in the release blog

Some errors in a program I'm developing

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 5.8k Views 3 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.
  • tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by tomy
    #1

    Hi all,

    I'm using the book C++-GUI-Programming-with-Qt-4-2nd Edition, and trying to create a spreadsheet application.
    That application occupies two chapters (3 and 4) of that book and I have prepared the files and codes in a project named MainWindow.
    There are some errors and I want to pose one of them each time so that I will make the app run successfully finally.
    Thanks for your help.

    The first error says the following in the main.cpp file:

    C:\Users\Abbasi\Documents\Qt\MainWindow\MainWindow\main.cpp:8: error: 'QSplashScreen' was not declared in this scope
    QSplashScreen
    splash = new QSplashScreen;
    ^*

    What .cpp or .h file should I check and remove the error please?

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      Hi,
      To be able to use 'QSplashScreen ' you have to include it like this :
      #include <QSplashScreen>

      LA

      1 Reply Last reply
      2
      • tomyT Offline
        tomyT Offline
        tomy
        wrote on last edited by tomy
        #3

        Thank you. The issue is solved.
        I have another error belonging to two functions, loadModules() and establishConnections(), lines 20 and 24 of the screenshot.

        They say:

        C:\Users\Abbasi\Documents\Qt\MainWindow\MainWindow\main.cpp:21: error: 'loadModules' was not declared in this scope
        loadModules();

        ^
        C:\Users\Abbasi\Documents\Qt\MainWindow\MainWindow\main.cpp:25: error: 'establishConnections' was not declared in this scope
        establishConnections();
        ^

        I looked the functions here to find the header files to include, but didn't find.

        mrjjM 1 Reply Last reply
        0
        • tomyT tomy

          Thank you. The issue is solved.
          I have another error belonging to two functions, loadModules() and establishConnections(), lines 20 and 24 of the screenshot.

          They say:

          C:\Users\Abbasi\Documents\Qt\MainWindow\MainWindow\main.cpp:21: error: 'loadModules' was not declared in this scope
          loadModules();

          ^
          C:\Users\Abbasi\Documents\Qt\MainWindow\MainWindow\main.cpp:25: error: 'establishConnections' was not declared in this scope
          establishConnections();
          ^

          I looked the functions here to find the header files to include, but didn't find.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @tomy said in Some errors in a program I'm developing:

          establishConnections
          loadModules()

          I think they are part of the sample. Not Qt.
          But seems not to be included in the book ?!?

          Maybe they are in the full source code
          http://www.informit.com/content/images/9780132354165/examples/qt-book-examples.zip

          Update: Nope. The source does not contain those calls at all.

          1 Reply Last reply
          1
          • tomyT Offline
            tomyT Offline
            tomy
            wrote on last edited by tomy
            #5

            I made those two functions be comments because they don't seem to be needed to the app.

            My other error in mainwindow.cpp is this.
            The error:

            C:\Users\Abbasi\Documents\Qt\MainWindow\MainWindow\mainwindow.cpp:26: error: 'setWindowIdon' was not declared in this scope

            Although I included the QIcon header file, the problem still exists. :(

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

              @tomy said in Some errors in a program I'm developing:

              setWindowIdon

              Hi,

              You have a typo: it's setWindowIcon.

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

              tomyT 1 Reply Last reply
              3
              • SGaistS SGaist

                @tomy said in Some errors in a program I'm developing:

                setWindowIdon

                Hi,

                You have a typo: it's setWindowIcon.

                tomyT Offline
                tomyT Offline
                tomy
                wrote on last edited by tomy
                #7

                @SGaist

                Yes, I had many other typos too. :) I corrected them. Thanks.
                Now the compiler shows only one error which belongs to the
                void MainWindow::sort() function in mainwindow.cpp.
                There are two codes in the book each with its error!

                The first code is:

                void MainWindow::sort()
                {
                    SortDialog dialog(this);
                    QTableWidgetSelectionRange range = spreadsheet -> selectedRange();
                    dialog.setColumnRange('A' + range.leftColumn(),
                                          'A' + range.rightColumn());
                
                    if(dialog.exec())
                        spreadsheet -> performSort(dialog.comparisonObject());
                }
                
                

                The errors:

                error: 'class Spreadsheet' has no member named 'performSort'
                spreadsheet -> performSort(dialog.comparisonObject());

                error: 'class SortDialog' has no member named 'comparisonObject'
                spreadsheet -> performSort(dialog.comparisonObject());

                The second code:

                void MainWindow::sort()
                {
                    SortDialog dialog(this);
                    dialog.setSpreadsheet(spreadsheet);
                    dialog.exec();
                }
                

                And the error:
                error: 'class SortDialog' has no member named 'setSpreadsheet'
                dialog.setSpreadsheet(spreadsheet);

                The errors are clear. The invoked functions don't exist in the corresponding classes.

                But why has the author written such codes? And how to solve them please?

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

                  What is the implementation of SortDialog ?

                  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
                  • tomyT Offline
                    tomyT Offline
                    tomy
                    wrote on last edited by
                    #9

                    It's sortdialog.cpp:

                    #include <QtWidgets>
                    #include "sortdialog.h"
                    
                    SortDialog::SortDialog(QWidget* parent)
                        : QDialog(parent)
                    {
                        setupUi(this);
                    
                        secondaryGroupBox -> hide();
                        tertiaryGroupBox -> hide();
                        layout() -> setSizeConstraint(QLayout::SetFixedSize);
                    
                        setColumnRange('A', 'Z');
                    }
                    
                    //*************************************************
                    
                    void SortDialog::setColumnRange(QChar first, QChar last)
                    {
                      primaryColumnCombo -> clear();
                      secondaryColumnCombo -> clear();
                      tertiaryColumnCombo -> clear();
                    
                      secondaryColumnCombo -> addItem(tr("None"));
                      tertiaryColumnCombo -> addItem(tr("None"));
                      primaryColumnCombo -> setMinimumSize(
                                 secondaryColumnCombo -> sizeHint());
                    
                      QChar ch = first;
                    
                      while(ch <= last)
                       {
                          primaryColumnCombo -> addItem(QString(ch));
                          secondaryColumnCombo -> addItem(QString(ch));
                          tertiaryColumnCombo -> addItem(QString(ch));
                          ch = ch.unicode() + 1;
                       }
                    }
                    

                    It has no setSpreadsheet function. So why has the book written that function for use!? :(

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

                      Isn't it rather the FilterDialog class and the function is initFromSpreadsheet ?

                      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
                      1
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Hi
                        When such errors, why dont you check with the supplied source code ?
                        The spreadsheet is chap03.

                        http://www.informit.com/content/images/9780132354165/examples/qt-book-examples.zip

                        1 Reply Last reply
                        2
                        • tomyT Offline
                          tomyT Offline
                          tomy
                          wrote on last edited by
                          #12

                          Hi,

                          Thank you. I ran the supplied code and with some modifications it worked successfully.
                          Now I'm at the beginning of chapter 5. The spreadsheet program is of chapters 3 and 4. Honestly speaking the code is very huge for a learner of Qt "at this point". although I have good experience of C++, it still needs much work to master the code completely. It contains more than 1500 lines of code!!

                          Since my goal is continuing Qt, I think I should by no way omit this subject and should completely understand the application. It's vast but I want to start it by reading and thinking about the codes for each header and .cpp file there.
                          Do you agree?
                          Do you want to add some comment for helping me?

                          Thanks.

                          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