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. Non-static data member warnings [SOLVED]

Non-static data member warnings [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 2.0k 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.
  • K Offline
    K Offline
    KGWAY
    wrote on last edited by KGWAY
    #1

    hello,

    I'm running into an abundant amount of non-static warnings for the way I'm setting up my layouts and buttons. The Project still works fine warnings and all.

    class Calibration : public QObject
    {
        Q_OBJECT
    public:
        explicit Calibration(QObject *parent = 0);
    
    public:
        QHBoxLayout *MainLayout = new QHBoxLayout;
        QTableWidget *table = new QTableWidget;
        QHBoxLayout *TableLayout = new QHBoxLayout;
        QVBoxLayout *buttonlayout= new QVBoxLayout;
    
        QPushButton *CalPA = new QPushButton("Save Cal");
        QPushButton *GetPA = new QPushButton("Get Cal");
        QPushButton *SaveFile = new QPushButton("Save to File");
        QPushButton *GetFile = new QPushButton("Recall File");
    
    
    private:
        QStringList m2_TableHeader;
    
    
    signals:
    
    public slots:
    
    };
    

    if I change everything to

     QHBoxLayout *MainLayout;
        QTableWidget *table;
        QHBoxLayout *TableLayout;
        QVBoxLayout *buttonlayout;
    
        QPushButton *CalPA;
        QPushButton *GetPA;
        QPushButton *SaveFile;
        QPushButton *GetFile ;
    

    this makes the warnings go away but the program crashes. I know the issue is I'm declaring them publicly but I need to use them in a separate class so I don't think I can do so while declaring them privately. Should I be concerned, what should I change to fix this?

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

      Hi,

      That's because you're trying to do in-class initialization without C++11 activated. Since you don't seem to use C++11 you must move them in the constructor.

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

        If I move them in the constructor they become static and I can't use them in my other class. The issue with that is I declare the buttons public in the header and then lay them out and show them In a separate class constructor(to make the code a little more readable). Would it be in bad taste just to leave it the way it is even if it works? Do you know of a solution where I can declare them in one constructor and use them in a completely different constructor?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KGWAY
          wrote on last edited by
          #4

          I solved my issue. Here is the Code:

          .h file

          public:
          
              QVBoxLayout *buttonlayout;
              QPushButton *CalPA;
              QPushButton *GetPA;
              QPushButton *SaveFile;
              QPushButton *GetFile;
          

          .ccp file

          buttonlayout= new QVBoxLayout;
              CalPA = new QPushButton("Save Cal");
              GetPA = new QPushButton("Get Cal");
              SaveFile = new QPushButton("Save to File");
              GetFile = new QPushButton("Recall File");
          

          Works, no warnings no crashes.

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

            Something sounds fishy: why are you trying to access these members from other widgets ?

            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
            • K Offline
              K Offline
              KGWAY
              wrote on last edited by
              #6

              What I actually wanted was to create and populate a tab in a UI in a separate class. then connect those buttons and what not with code in the MainWindow class. But I actually decided to move most of the initialization back over to the Mainwindow, because of issues with it correctly updating information.

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

                @koahnig double check your settings, the mailing option should be there to configure it.

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

                K 1 Reply Last reply
                0
                • SGaistS SGaist

                  @koahnig double check your settings, the mailing option should be there to configure it.

                  K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  @SGaist
                  Apparently landed in the wrong place.
                  Anyway, I am typically simply checking stuff with the Alarm bell symbol in the top row.
                  All mailings do not help at all, because for sure I am not checking those or only occassionally at most.

                  Vote the answer(s) that helped you to solve your issue(s)

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

                    The notifications bell doesn't seem to always return the data corresponding to the number it shows

                    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

                    • Login

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