qcheckbox SLOT doesnot get called on clicked



  • Hello everyone,
    this problem is supposed not to be a problem but i dont know how it arises.
    I added a check box widget and am trying to read it status in its slot (clicked).

    But its not going to its slot. I tried putting a break point on its slot function but it does not come to that point on being clicked.

    Kindly provide some solutions.

    Thanks



  • @Sumit
    Can you show us your code?



  • HI,

    @Sumit

    1. Have u provided macro Q_OBJECT.?
    2. And the function to be called, SLOT , is it under public /private SLOT() section, ?

    And as @dream_captain said , can u provide the code.

    Thanks,



  • @dream_captain

    This function was working previously.
    I tried both the ways: Signal and slots and also through ui (right click and go to slot).
    The below code is not as it is in my workspace. i had added the important info regarding Qcheckbox

    code::
    some.hpp

    #include <QWidget>
    #include "common/abs_includes.hpp"
    #include "core/abs_va_ucf_handler.hpp"
    #include <QtWidgets/QDialog>
    #include "qdialog.h"
    #include <QtWidgets/qwidget.h>
    #include "QtWidgets/QMessageBox"
    #include "QtWidgets/qcombobox.h"
    #include  "QtWidgets/qformlayout.h"
    #include "QtWidgets/qspinbox.h"
    #include "QtWidgets/qradiobutton.h"
    #include "qstandarditemmodel.h"
    #include "userinterface/qcombocheckbox.hpp"
    #include "qlineedit.h"
    #include "qcheckbox.h"
    #include "qtextstream.h"
    #include "qgroupbox.h"
    #include "qlabel.h"
    
    
    class CAbsDptUIFilterPanel : public QWidget
    {
        Q_OBJECT
    public: 
         some functions
    
    private slots:
     void on_checkBox_showGallery_clicked();
    
       void onCheckBoxShowGalleryClicked(bool f_bool);
    }
    
    something.cpp
    void CAbsDptUIFilterPanel::on_checkBox_showGallery_clicked()
    {
        m_showGallerySamples = ui->checkBox_showGallery->isChecked();
    }
    
    void CAbsDptUIFilterPanel::onCheckBoxShowGalleryClicked(bool f_bool)
    {
        m_showGallerySamples = f_bool;
    }
    

    I had noticed that moc file for this this file is not getting generated.



  • Can u clean , run qmake and build it.

    Thanks,



  • @Pradeep-Kumar tried many times



  • Can u delete the build folder then compile once again,

    Thanks,



  • does some functions contain a constructor? if so, can you show it?
    Basically, slots are not magically connected, you have to call QObject::connect in the constructor (or let uic take care of connections based by name)



  • @Sumit ,

    Where is your connect statement for 2nd slot.



  • @VRonin

    CAbsDptUIFilterPanel::CAbsDptUIFilterPanel (CAbsDptController*                       f_dptController,
                                                QMainWindow *parent)
        :   m_mainWindow(parent),
          m_dptController(f_dptController),
          ui(new Ui::CDPTUIFilterPanel)
    {
        ui->setupUi(this);
        this->setWindowTitle("Filter Panel");
        //setWindowIcon(QIcon(":Images/Images/BAS_lcon.png"));
        //adding project name to the filter panel
        add_project_name_to_filter_panel_display();
    
        ui->m_gallery_spinBox->setRange(0,100);
        ui->m_train_spinBox->setRange(0,100);
    
        ui->m_gallery_spinBox->setEnabled(true);
        ui->m_train_spinBox->setEnabled(true);
        m_showGallerySamples=true;
        ui->checkBox_showGallery->setChecked(true);
        CAbsDptController::getFilterTabNames(m_strFilterTabNames);
        createFilterTabs();
        m_FilterPanelHolder_p = NULL;
        m_FilterPanelHolder_p = new QDockWidget("Filter View",m_mainWindow);
        m_FilterPanelHolder_p->setAllowedAreas(Qt::LeftDockWidgetArea);
        m_FilterPanelHolder_p->setFeatures(QDockWidget::AllDockWidgetFeatures);
    
        m_scrollArea = new QScrollArea();
    
        CAbsDptWorkspace *l_workSpace_p = (CAbsDptWorkspace*)m_mainWindow;
    
        m_scrollArea->setGeometry(l_workSpace_p->geometry());
        m_scrollArea->setWidgetResizable(true);
    
        this->setFixedWidth((m_mainWindow->width()/4)-30);
        m_scrollArea->setWidget(this);
    
        m_FilterPanelHolder_p->setWidget(m_scrollArea);
        m_FilterPanelHolder_p->setFeatures(QDockWidget::DockWidgetFloatable |
                                           QDockWidget::DockWidgetMovable);
        m_FilterPanelHolder_p->setMaximumWidth(m_mainWindow->width()/4);
    
        m_mainWindow->addDockWidget(Qt::LeftDockWidgetArea, m_FilterPanelHolder_p);
    
        connect(ui->checkBox_showGallery,SIGNAL(clicked(bool)), this,SLOT(onCheckBoxShowGalleryClicked(bool)));
    


  • @Pradeep-Kumar

    Thanks it worked.

    deleted the whole folder and rebuild the project it started pointing to the break point.



  • @Sumit

    Glad u got the result,
    Happy Coding,

    Thanks,


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.