¨[solved] - public slots in MainWindow
-
hi,
is anywhere described how to create a public slot in MainWindow?
I already have a tabWidget as a centralWidget and I'm interested to add a public slot that will open any new form/widget in a new tab, inside the mainWindow. this slot should be consumed by a pushButton.
thank you. -
Hii
You need to read this
http://qt-project.org/doc/qt-4.8/signalsandslots.html -
I knew this post, but I didn't pay attention when I read it.
basically in mainwindow.h I declared:
@public slots:
void addNewTab(QWidget *page, QString &title)
{
QTabWidget *newTab = new QTabWidget;
newTab->setTabsClosable(true);
newTab->setMovable(true);
connect(newTab, SIGNAL(tabCloseRequested(int)), newTab, SLOT (close()));setCentralWidget(newTab); newTab->addTab(page, title); }
@
when I call it from mainwindow.cpp
@void MainWindow::on_addUser_triggered()
{
usernew *nU = new usernew;
QString title = "Add User";
addNewTab(nU, title);
}
@that solved the issue. thank you for your guidelines.