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. ¨[solved] - public slots in MainWindow

¨[solved] - public slots in MainWindow

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views 1 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.
  • A Offline
    A Offline
    angelicaP
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      Hii
      You need to read this
      http://qt-project.org/doc/qt-4.8/signalsandslots.html

      Be Cute

      1 Reply Last reply
      0
      • A Offline
        A Offline
        angelicaP
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

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