¨[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.

  • 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;
    connect(newTab, SIGNAL(tabCloseRequested(int)), newTab, SLOT (close()));

        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.

Log in to reply

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