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.
  • ademmlerA Offline
    ademmlerA Offline
    ademmler
    wrote on 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
    • nageshN Offline
      nageshN Offline
      nagesh
      wrote on last edited by
      #2

      @ademmler check here

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

      ademmlerA 1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on 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);
        
        ademmlerA 1 Reply Last reply
        0
        • nageshN nagesh

          @ademmler check here

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

          ademmlerA Offline
          ademmlerA Offline
          ademmler
          wrote on last edited by
          #4

          @nagesh Yi are right - I corrected it - thx

          1 Reply Last reply
          0
          • mrjjM mrjj

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

              connect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);
            
            ademmlerA Offline
            ademmlerA Offline
            ademmler
            wrote on 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
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 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

              ademmlerA 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @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.

                ademmlerA Offline
                ademmlerA Offline
                ademmler
                wrote on 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
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 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

                  • Login

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