I have a mainWindow class that calls a function mainWIndow::ShowDialogBox()
when double clicked on the QTabBar. The dialog box shows up, but it isn't connecting the buttons. I have the connect calls in ShowDialogBox. It gives me a red underline on connect saying
no instance of overloaded function "MainWindow::connect" matches the argument list"
This is my code
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
if (object == mTabWidget->getTabBar() && event->type() == QEvent::MouseButtonDblClick)
{
qDebug()<<"dblclk";
ShowDialogBox();
}
return QObject::eventFilter(object, event);
}
//Show dialog box when double clicked on QTabBar
void MainWindow::ShowDialogBox(){
QDialog dialog;
QVBoxLayout layout(&dialog);
QLineEdit editLine;
layout.addWidget(&editLine);
QDialogButtonBox *dialogButton = new QDialogButtonBox(QDialogButtonBox::Ok );
connect(dialogButton, SIGNAL(accepted()), dialog, SLOT(accept())); //this 'connect' is underlined
layout.addWidget(dialogButton);
dialog.setLayout(&layout);
if(dialog.exec() == QDialog::Accepted)
{
mTabWidget->setTabText(0, editLine.text());
}
}
I have added the signals and slot in mainWindow.h as
private slots:
void accept();
signals:
void accepted();
I have spend hours on this but no luck. I am new to Qt.
Line:
should be:
Because the third parameter has to be a memory address(pointer).