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. How to connect default QDialogButtonBox
Forum Updated to NodeBB v4.3 + New Features

How to connect default QDialogButtonBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 1.0k 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
    ademmler
    wrote on 18 May 2021, 14:19 last edited by ademmler
    #1

    Hi folks,

    in my class I am using a QDialogButtonBox. The UI has been made with QtCreator.
    How do I connect those buttons using the NEW syntax?
    I tried the code below but I get "error: no matching member function for call to 'connect'

    #include "mycomments.h"
    #include "ui_mycomments.h"
    
    MyComments::MyComments(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::MyComments)
    {
        ui->setupUi(this);
    
        connect(this, ui->dialogButtonBox->button(QDialogButtonBox::Apply), this, &MyComments::slotApplyComment);
    }
    
    MyComments::~MyComments()
    {
        delete ui;
    }
    
    
    void slotApplyComment()
    {
    
    }
    
    1 Reply Last reply
    0
    • N Offline
      N Offline
      nagesh
      wrote on 18 May 2021, 14:35 last edited by
      #2

      @ademmler check here

      looks like slotApplyComment() is not member function.
      Syntax also wrong here

      A 1 Reply Last reply 18 May 2021, 17:50
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 18 May 2021, 14:48 last edited by
        #3

        Hi
        Your connect is a bit odd.
        Should not be like

          connect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);
        
        A 1 Reply Last reply 18 May 2021, 17:52
        0
        • N nagesh
          18 May 2021, 14:35

          @ademmler check here

          looks like slotApplyComment() is not member function.
          Syntax also wrong here

          A Offline
          A Offline
          ademmler
          wrote on 18 May 2021, 17:50 last edited by
          #4

          @nagesh Yi are right - I corrected it - thx

          1 Reply Last reply
          0
          • M mrjj
            18 May 2021, 14:48

            Hi
            Your connect is a bit odd.
            Should not be like

              connect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);
            
            A Offline
            A Offline
            ademmler
            wrote on 18 May 2021, 17:52 last edited by
            #5

            @mrjj said in How to connect default QDialogButtonBox:

            connect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);

            This gives me:
            mycomments.cpp:10:68: error: incomplete type 'QPushButton' named in nested name specifier
            qdialog.h:51:7: note: forward declaration of 'QPushButton'

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 18 May 2021, 17:53 last edited by
              #6

              @ademmler said in How to connect default QDialogButtonBox:

              qdialog.h:51:7: note: forward declaration of 'QPushButton'

              c++ basics - when you want to use a class you have to make sure the compiler sees it by e.g. including the header where it's defined.

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

              A 1 Reply Last reply 18 May 2021, 17:54
              1
              • C Christian Ehrlicher
                18 May 2021, 17:53

                @ademmler said in How to connect default QDialogButtonBox:

                qdialog.h:51:7: note: forward declaration of 'QPushButton'

                c++ basics - when you want to use a class you have to make sure the compiler sees it by e.g. including the header where it's defined.

                A Offline
                A Offline
                ademmler
                wrote on 18 May 2021, 17:54 last edited by
                #7

                @Christian-Ehrlicher You where faster ... just got it and wanted to delete my post ...
                But honestly - c++ error messages are not very clear ;-)

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 18 May 2021, 17:55 last edited by
                  #8

                  Apart from this - why not simply using QDialogButtonBox::accepted()

                  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
                  1

                  1/8

                  18 May 2021, 14:19

                  • Login

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