Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Nested Map QDialog sharing
Forum Updated to NodeBB v4.3 + New Features

Nested Map QDialog sharing

Scheduled Pinned Locked Moved Unsolved C++ Gurus
4 Posts 2 Posters 502 Views 2 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.
  • A Offline
    A Offline
    ASCsk
    wrote on last edited by
    #1

    I have this class:

    namespace Ui {
    class Components;
    }
    
    class Components : public QDialog
    {
        Q_OBJECT
        void AddRoot(QString name, QString codigo, int quantidade);
    public:
        explicit Components(QWidget *parent = nullptr);
        ~Components();    
    private slots:    
        void on_pbAdd_clicked();
        void on_pbSearch_clicked();
        void on_pbDelete_clicked();
    protected:     
         QMap<QString, QMap<QString, int>>  CompMap; 
    private:
        Ui::Components *ui;
    

    and this class:

    namespace Ui {
    class Calendario;
    }
    
    class Calendario : public QDialog
    {
       
    public:
        explicit Calendario(QWidget *parent = nullptr);
        ~Calendario();
        
        Q_OBJECT
    
    public slots:   
        void setValuesCal(QMap<QString, QMap<QString, int>>);
    signals:  
        void valueChengedCal(QMap<QString, QMap<QString, int>>);    
    private slots:
       
        void setReservation(QDate &date);
        void getReservation(QDate &date);
        void delReservation(QDate &date);
        QDate on_calendarWidget_clicked(const QDate &date);
        void on_lineEdit_textChanged(const QString &nome);
        void on_lineEdit_2_textChanged(const QString &codigo);
    
    private:
        void setFontSize(int size);
    
        Ui::Calendario *ui;
        QDate * selecteddate;
        
    
    

    I add,remove and edit all values of the QMap in the Components and I want to be able to edit only int value of said QMap on my class Calendario.
    Fist question is: is this a good approach to the subject.
    Second question: how would I go about sharing the data in one Dialog and the other since, as I understand it it, I can't pass it as a signal.

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

      Hi and welcome to devnet,

      If you only want to change the int values contained in CompMap then give Components a proper API that allows to give the parameters need to make that happen.

      As for the design question, based on the code, it's likely not going to be clean. Can you explain exactly what you want to implement ?

      The naming itself is so generic that it does not allow to really give an answer.

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

        i'm implementing and item electronic component management system system.
        I have those two classes. and a main window.

        In main window I just have 2 functions which are used to open the dialogs:

        void MainWindow::on_actionComp_Manager_triggered()
        {
            Component = new Components;
            Component->show();
        }
        
        void MainWindow::on_actionReservas_triggered()
        {
            Calendar = new Calendario;
            Calendar ->show();
        }
        

        The components class is where I add items to map which have:
        name = fist map key (QString)
        code = nested map key (QString)
        number_of_items = nested map value(int)

        The map is up and running and I can manage them.

        The Calendario class is a calendar where I need to:

        pick a code and pick a number_of_items from said Map and select a date from calendar;
        I used this to get the date:

        QDate Calendario::on_calendarWidget_clicked(const QDate &date)
        {
            *selecteddate = date;
            qDebug() << *selecteddate;
            return *selecteddate;
        }
        

        and remove said item quantity from that map for as long as the day picked isn't over.

        And I will eventually need to get that info on file.

        I was going to create map in the Calendario class to store the codes and quantities extracted from the other map and save them individually.

        I would really appreciate the help. I went through the Documentation but I don't seem to find a way.
        Thanks in advance

        SGaistS 1 Reply Last reply
        0
        • A ASCsk

          i'm implementing and item electronic component management system system.
          I have those two classes. and a main window.

          In main window I just have 2 functions which are used to open the dialogs:

          void MainWindow::on_actionComp_Manager_triggered()
          {
              Component = new Components;
              Component->show();
          }
          
          void MainWindow::on_actionReservas_triggered()
          {
              Calendar = new Calendario;
              Calendar ->show();
          }
          

          The components class is where I add items to map which have:
          name = fist map key (QString)
          code = nested map key (QString)
          number_of_items = nested map value(int)

          The map is up and running and I can manage them.

          The Calendario class is a calendar where I need to:

          pick a code and pick a number_of_items from said Map and select a date from calendar;
          I used this to get the date:

          QDate Calendario::on_calendarWidget_clicked(const QDate &date)
          {
              *selecteddate = date;
              qDebug() << *selecteddate;
              return *selecteddate;
          }
          

          and remove said item quantity from that map for as long as the day picked isn't over.

          And I will eventually need to get that info on file.

          I was going to create map in the Calendario class to store the codes and quantities extracted from the other map and save them individually.

          I would really appreciate the help. I went through the Documentation but I don't seem to find a way.
          Thanks in advance

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @ASCsk said in Nested Map QDialog sharing:

          QDate Calendario::on_calendarWidget_clicked(const QDate &date)
          {
          *selecteddate = date;
          qDebug() << *selecteddate;
          return *selecteddate;
          }

          This screams for cleanup. There's no need to allocate a QDate on the heap.

          In any case, from your description, you should really consider using a database. Please take the time to go through the corresponding chapter in Qt's documentation as well as read the examples.

          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

          • Login

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