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. Form problem
Qt 6.11 is out! See what's new in the release blog

Form problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.1k 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.
  • Z Offline
    Z Offline
    ZekDe
    wrote on last edited by
    #1

    Hi friends,
    I am connecting PLC with snap7 object and when I click the button in another form,I must send an information.How can I provide this with this same object.Do I have to create a new snap7 object in other form.

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

      Hi
      Are both form in same application ?

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZekDe
        wrote on last edited by
        #3

        I will do like this,emitting a signal from other forms to mainwindow it is okay but new problem is I cant catch which button clicked

        QPushButton *DKCS_btnx[]= {ui->DKCS_btn1,ui->DKCS_btn2,ui->DKCS_btn3,ui->DKCS_btn4,ui->DKCS_btn5,ui->DKCS_btn6};
        for(int i=0;i<6;i++)
        connect(DKCS_btnx[i],SIGNAL(clicked(bool)),this,SLOT(ButtonHandler()));

        void dialogDKCS::ButtonHandler()
        {
        QPushButton *button = (QPushButton *)sender();
        // ui->DKCS_btn1->setText(QString::number(button->text()[0].digitValue()));
        ui->DKCS_btn1->setText(QString::number(button->));
        QPushButton btn = (QPushButton)senderSignalIndex();
        //ui->DKCS_btn2->setText(QString::number(btn->text().at(0)));

        }

        I need button index

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

          Hi,

          Sounds like a job for QSignalMapper.

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

            Hi
            Why you need the index when you have the button that was click in "button " ?
            Just need to cast it like

            QPushButton *button = qobject_cast<QPushButton *>( sender() );
            if (button){
            button->text ...
            }

            but as @SGaist says, a signal mapper might work better.

            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