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. Data passing

Data passing

Scheduled Pinned Locked Moved Unsolved General and Desktop
dataflowbuttonsgui
8 Posts 3 Posters 2.8k 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.
  • J Offline
    J Offline
    jklms
    wrote on last edited by jklms
    #1

    Hi, I'm student from CR. I'm self taught programmer. I am developing GUI application and I struggle with passing data between slots.

    I have two slots

    mySlot::on_buttonSetValue_clicked(){

    Qstring qx = ui->lineEdit->setText();
    double x=qx.toDouble();

    }
    mySlot::on_buttonShow_clicked(){

    ui->textBrowser->setText( ? )

    }

    I know how to pass data to a slot, with emitting signal from slot one and connecting it to a slot, which will receive the emitted signal with the parameter, but that will automatically execute the whole slot, if you know what I mean. I want the slot to be executed on button clicked() signal. In my case I want on_buttonShow_clicked() to be executed on signal clicked() (which it does, of course) while using data from on buttonSetValue_clicked(). Do I need an extra space to store the variables in?

    I have read something about QSharedMemory class, but i can not get it to work, and also I am not sure whether it is the best way to approach. I have read many questions and answers on this topic, but every time the whole slot is executed while the data are passed to it. I'll be glad for any advice. Thank you

    jsulmJ 3 Replies Last reply
    0
    • J jklms

      Hi, I'm student from CR. I'm self taught programmer. I am developing GUI application and I struggle with passing data between slots.

      I have two slots

      mySlot::on_buttonSetValue_clicked(){

      Qstring qx = ui->lineEdit->setText();
      double x=qx.toDouble();

      }
      mySlot::on_buttonShow_clicked(){

      ui->textBrowser->setText( ? )

      }

      I know how to pass data to a slot, with emitting signal from slot one and connecting it to a slot, which will receive the emitted signal with the parameter, but that will automatically execute the whole slot, if you know what I mean. I want the slot to be executed on button clicked() signal. In my case I want on_buttonShow_clicked() to be executed on signal clicked() (which it does, of course) while using data from on buttonSetValue_clicked(). Do I need an extra space to store the variables in?

      I have read something about QSharedMemory class, but i can not get it to work, and also I am not sure whether it is the best way to approach. I have read many questions and answers on this topic, but every time the whole slot is executed while the data are passed to it. I'll be glad for any advice. Thank you

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @jklms Sorry, but your question is unclear. What data do you want to pass? Who is passing the data to whom?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        http://www.cplusplus.com/doc/tutorial/classes/

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • J jklms

          Hi, I'm student from CR. I'm self taught programmer. I am developing GUI application and I struggle with passing data between slots.

          I have two slots

          mySlot::on_buttonSetValue_clicked(){

          Qstring qx = ui->lineEdit->setText();
          double x=qx.toDouble();

          }
          mySlot::on_buttonShow_clicked(){

          ui->textBrowser->setText( ? )

          }

          I know how to pass data to a slot, with emitting signal from slot one and connecting it to a slot, which will receive the emitted signal with the parameter, but that will automatically execute the whole slot, if you know what I mean. I want the slot to be executed on button clicked() signal. In my case I want on_buttonShow_clicked() to be executed on signal clicked() (which it does, of course) while using data from on buttonSetValue_clicked(). Do I need an extra space to store the variables in?

          I have read something about QSharedMemory class, but i can not get it to work, and also I am not sure whether it is the best way to approach. I have read many questions and answers on this topic, but every time the whole slot is executed while the data are passed to it. I'll be glad for any advice. Thank you

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @jklms Why don't you just set the value in on_buttonSetValue_clicked()?

          mySlot::on_buttonSetValue_clicked(){
              Qstring qx = ui->lineEdit->setText();
              double x=qx.toDouble();
              ui->textBrowser->setText(QString::number(x);
          }
          

          If you want to delay the new value to be shown until on_buttonShow_clicked() is called store the calculated value in a class variable:

          class mySlot
          {
          ...
          private:
              double x;
          };
          
          void mySlot::on_buttonSetValue_clicked()
          {
              Qstring qx = ui->lineEdit->setText();
              x=qx.toDouble(); // x is declared in the class as private
          }
          
          void mySlot::on_buttonShow_clicked()
          {
              ui->textBrowser->setText(QString::number(x));
          }
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 2 Replies Last reply
          1
          • J jklms

            Hi, I'm student from CR. I'm self taught programmer. I am developing GUI application and I struggle with passing data between slots.

            I have two slots

            mySlot::on_buttonSetValue_clicked(){

            Qstring qx = ui->lineEdit->setText();
            double x=qx.toDouble();

            }
            mySlot::on_buttonShow_clicked(){

            ui->textBrowser->setText( ? )

            }

            I know how to pass data to a slot, with emitting signal from slot one and connecting it to a slot, which will receive the emitted signal with the parameter, but that will automatically execute the whole slot, if you know what I mean. I want the slot to be executed on button clicked() signal. In my case I want on_buttonShow_clicked() to be executed on signal clicked() (which it does, of course) while using data from on buttonSetValue_clicked(). Do I need an extra space to store the variables in?

            I have read something about QSharedMemory class, but i can not get it to work, and also I am not sure whether it is the best way to approach. I have read many questions and answers on this topic, but every time the whole slot is executed while the data are passed to it. I'll be glad for any advice. Thank you

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @jklms said in Data passing:

            QSharedMemory

            this is used for Inter Process Communication and is something completely different!

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • jsulmJ jsulm

              @jklms Why don't you just set the value in on_buttonSetValue_clicked()?

              mySlot::on_buttonSetValue_clicked(){
                  Qstring qx = ui->lineEdit->setText();
                  double x=qx.toDouble();
                  ui->textBrowser->setText(QString::number(x);
              }
              

              If you want to delay the new value to be shown until on_buttonShow_clicked() is called store the calculated value in a class variable:

              class mySlot
              {
              ...
              private:
                  double x;
              };
              
              void mySlot::on_buttonSetValue_clicked()
              {
                  Qstring qx = ui->lineEdit->setText();
                  x=qx.toDouble(); // x is declared in the class as private
              }
              
              void mySlot::on_buttonShow_clicked()
              {
                  ui->textBrowser->setText(QString::number(x));
              }
              
              J Offline
              J Offline
              jklms
              wrote on last edited by
              #6

              @jsulm said in Data passing:

              ui->textBrowser->setText(QString::number(x);

              In my application, I read data into a buffer in first slot, then I want to have time to choose what analyze i want to run on my data, and then when I click on button Analyze, i want to work with the data in the buffer and with the input from the user about the analysis

              jsulmJ 1 Reply Last reply
              0
              • J jklms

                @jsulm said in Data passing:

                ui->textBrowser->setText(QString::number(x);

                In my application, I read data into a buffer in first slot, then I want to have time to choose what analyze i want to run on my data, and then when I click on button Analyze, i want to work with the data in the buffer and with the input from the user about the analysis

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @jklms See my previous reply - I updated it.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @jklms Why don't you just set the value in on_buttonSetValue_clicked()?

                  mySlot::on_buttonSetValue_clicked(){
                      Qstring qx = ui->lineEdit->setText();
                      double x=qx.toDouble();
                      ui->textBrowser->setText(QString::number(x);
                  }
                  

                  If you want to delay the new value to be shown until on_buttonShow_clicked() is called store the calculated value in a class variable:

                  class mySlot
                  {
                  ...
                  private:
                      double x;
                  };
                  
                  void mySlot::on_buttonSetValue_clicked()
                  {
                      Qstring qx = ui->lineEdit->setText();
                      x=qx.toDouble(); // x is declared in the class as private
                  }
                  
                  void mySlot::on_buttonShow_clicked()
                  {
                      ui->textBrowser->setText(QString::number(x));
                  }
                  
                  J Offline
                  J Offline
                  jklms
                  wrote on last edited by jklms
                  #8

                  @jsulm Oh. I haven't considered that. I'm definitely going to try that. I don't know why it didn't came to my mind. Thank you very much. I really appreciate your advice. I have been stuck at this problem for a week. I am glad there are people who are willing to help beginners.

                  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