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. Problem with dialog child
Forum Updated to NodeBB v4.3 + New Features

Problem with dialog child

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 5 Posters 3.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.
  • C Offline
    C Offline
    Charlie_Hdz
    wrote on last edited by
    #2

    Do you mean that "test dialog" output was prompted twice?

    Kind Regards,
    Enrique Hernandez
    gearstech.com.mx
    chernandez@gearstech.com.mx

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pantof
      wrote on last edited by
      #3

      Yes, the on_pushbutton_clicked is called twice

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Charlie_Hdz
        wrote on last edited by Charlie_Hdz
        #4

        @Pantof

        Can you share the output, please?

        Kind Regards,
        Enrique Hernandez
        gearstech.com.mx
        chernandez@gearstech.com.mx

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pantof
          wrote on last edited by
          #5

          this happens when only one return in line edit is pressed:
          ![alt text](0_1515023968801_30c94d4e-5d5e-4dcc-b465-d4aa33c2f9cd-immagine.png image url)

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Pantof
            wrote on last edited by
            #6

            I try another way with the same result:

            
            Dialog::Dialog(QWidget *parent) :
                QDialog(parent),
                ui(new Ui::Dialog)
            {
                ui->setupUi(this);
                QObject::connect(ui->lineEdit,&QLineEdit::returnPressed,this,&Dialog::onReturnPressed);
                QObject::connect(ui->pushButton, &QPushButton::clicked, this, &Dialog::onReturnPressed);
            }
            
            Dialog::~Dialog()
            {
                delete ui;
            }
            
            void Dialog::onReturnPressed()
            {
                qDebug()<< "test dialog ";
                qDebug()<< "dsdas";
            }
            
            

            it seems there is a problem between signal click() and clicked()

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mpergand
              wrote on last edited by mpergand
              #7

              It's normal, a dialog has a defaut button, when pressing enter, the defaut button emits the clicked signal.

              see: default button

              P 1 Reply Last reply
              1
              • C Offline
                C Offline
                Charlie_Hdz
                wrote on last edited by
                #8

                @Pantof

                Can you share the declarations (.h) of your classes?

                In the while, can you try to develop this project without using the Design to see what happens?

                Kind Regards,
                Enrique Hernandez
                gearstech.com.mx
                chernandez@gearstech.com.mx

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

                  Hi
                  I agree with @mpergand and also thinks its the dialog helping.

                  Pressing enter in line edits triggers this

                  QObject::connect(ui->lineEdit,&QLineEdit::returnPressed,this,&Dialog::onReturnPressed);
                  However, the lineedit do not eat the enter. its send to button.
                  the button is "default" (when created with Designer at least) meaning pressing enter
                  trigger it and it emits
                  QObject::connect(ui->pushButton, &QPushButton::clicked, this, &Dialog::onReturnPressed);

                  JonBJ 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Hi
                    I agree with @mpergand and also thinks its the dialog helping.

                    Pressing enter in line edits triggers this

                    QObject::connect(ui->lineEdit,&QLineEdit::returnPressed,this,&Dialog::onReturnPressed);
                    However, the lineedit do not eat the enter. its send to button.
                    the button is "default" (when created with Designer at least) meaning pressing enter
                    trigger it and it emits
                    QObject::connect(ui->pushButton, &QPushButton::clicked, this, &Dialog::onReturnPressed);

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #10

                    I don't understand what the problem here is.

                    There are two separate signals going on here.

                    • You have clicked RETURN in a QLineEdit, and you have chosen to catch that signal.

                    • Since QLineEdit, unlike QTextEdit, is single-line, it does not accept RETURN. So it passes it on to the QDialog to handle. Which (as @mpergand said) has a default button, which is invoked when RETURN is pressed. That only happens in a dialog, not a window.

                    What is the issue? The obvious question is why you are interested in handling QLineEdit::returnPressed() signal at all?

                    1 Reply Last reply
                    0
                    • M mpergand

                      It's normal, a dialog has a defaut button, when pressing enter, the defaut button emits the clicked signal.

                      see: default button

                      P Offline
                      P Offline
                      Pantof
                      wrote on last edited by
                      #11

                      you're all right sorry for ignorance,
                      i'm intrested in QLineEdit::returnPressed because with this dialog a user could insert more than 1 record in database and he could do it with returnPressed from QLineEdit.
                      i think i should do it in another way :D

                      JonBJ 1 Reply Last reply
                      0
                      • P Pantof

                        you're all right sorry for ignorance,
                        i'm intrested in QLineEdit::returnPressed because with this dialog a user could insert more than 1 record in database and he could do it with returnPressed from QLineEdit.
                        i think i should do it in another way :D

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #12

                        @Pantof
                        Nothing to be sorry for!

                        i'm intrested in QLineEdit::returnPressed because with this dialog a user could insert more than 1 record in database and he could do it with returnPressed from QLineEdit.

                        What do you mean by this?

                        It sounds a little odd, but if you have a legitimate reason it may be that the better solution is to prevent that RETURN from causing the default dialog action. The principle QDialog is working on is that a RETURN --- unless it is intended for the current widget --- is aimed at the dialog. That sounds like it may not correspond to what you are intending.

                        P 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @Pantof
                          Nothing to be sorry for!

                          i'm intrested in QLineEdit::returnPressed because with this dialog a user could insert more than 1 record in database and he could do it with returnPressed from QLineEdit.

                          What do you mean by this?

                          It sounds a little odd, but if you have a legitimate reason it may be that the better solution is to prevent that RETURN from causing the default dialog action. The principle QDialog is working on is that a RETURN --- unless it is intended for the current widget --- is aimed at the dialog. That sounds like it may not correspond to what you are intending.

                          P Offline
                          P Offline
                          Pantof
                          wrote on last edited by Pantof
                          #13

                          @JonB
                          normally the application show show a table from database when you click a pushbutton you open a Form (done with qDialog) that give you the possibility to insert new records. to speed up this job i use the return pressed from qLineEdit so you shouldn't move out to grab the mouse.
                          actually i switch to qWidget.

                          JonBJ 1 Reply Last reply
                          0
                          • P Pantof

                            @JonB
                            normally the application show show a table from database when you click a pushbutton you open a Form (done with qDialog) that give you the possibility to insert new records. to speed up this job i use the return pressed from qLineEdit so you shouldn't move out to grab the mouse.
                            actually i switch to qWidget.

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #14

                            @Pantof

                            i use the return pressed from qLineEdit

                            If you choose to do that, I would think you need to not let that key/return press to do it's normal action of activating the dialog's default button action. Such as, you could use event filter on the dialog perhaps. Or, I imagine a QDialog can be told not to have a default button/return press.

                            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