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. QVector<double> attributes
Forum Updated to NodeBB v4.3 + New Features

QVector<double> attributes

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 467 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.
  • AlbatorA Offline
    AlbatorA Offline
    Albator
    wrote on last edited by Albator
    #1

    Hey qt people,

    I have a little question to make multiple attributes in my .h

    to create several objects of the same type I use this method:

    //.h
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    private :
    std::vector<QLCDNumber*> lcd;
    
    //.cpp
    for (int i=0; i<22; i++) 
           {
    
            lcd.push_back(new QLCDNumber(this));
    
    
           }
    
    

    for lcd (objects) it works perfectly. to make vectors of QVector<double> id in the .h and use them in the .cpp how to do ?
    I have to create 90 of them and I would like to avoid writing in the .h :

        QVector<double> one_vector
        QVector<double> two_vector
        QVector<double> three_vector
                //
                //
                //
        QVector<double>  xx_vector
    

    if you have an idea, that's cool!
    thanks all and take care of you :)

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Albator said in QVector<double> attributes:

      QVector<double> 15

      What should this be?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • AlbatorA Offline
        AlbatorA Offline
        Albator
        wrote on last edited by
        #3

        it's the name if you prefer i can name this QVector<double> chips1

        B 1 Reply Last reply
        0
        • AlbatorA Albator

          it's the name if you prefer i can name this QVector<double> chips1

          B Offline
          B Offline
          Bonnie
          wrote on last edited by Bonnie
          #4

          @Albator
          If the vectors are member variables they must be written in the .h.
          Or you just don't want to write 90 times in .h?
          Then how about an array of vectors, or a vector of vectors?

          QVector<double> vectors[90];
          

          or

          QVector<QVector<double>> vectors;
          
          AlbatorA 1 Reply Last reply
          2
          • B Bonnie

            @Albator
            If the vectors are member variables they must be written in the .h.
            Or you just don't want to write 90 times in .h?
            Then how about an array of vectors, or a vector of vectors?

            QVector<double> vectors[90];
            

            or

            QVector<QVector<double>> vectors;
            
            AlbatorA Offline
            AlbatorA Offline
            Albator
            wrote on last edited by Albator
            #5

            @Bonnie yes is members variables

            the solution was super simple I don't know why I got confused about making std::vector<QVector<double>> xx [90];

            thanks @Bonnie :)))

            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