Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED]CloseEvent() when closing of a QDocWidget created with Designer?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]CloseEvent() when closing of a QDocWidget created with Designer?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.5k 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.
  • F Offline
    F Offline
    FRAUBRJ
    wrote on last edited by
    #1

    Hello
    I built my application with Qt Designer for the UI part. A main window (QWidget) where does the program, and several auxiliary Windows (QDockWidget) I call to make the settings.
    An auxiliary window appears when the menu is selected (Preferences…).
    My program begins with

    @//-----------------------------------------------------------------------------
    // My_MainWindow Constructor
    //-----------------------------------------------------------------------------
    My_MainWindow::My_MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::My_MainWindow)
    {
    ui->setupUi(this);
    .....
    createActions();
    createMenus();
    .....
    prefAction = new QAction("&Preferences", this);
    connect(prefAction, SIGNAL(triggered()), this, SLOT(preferenceAct()));
    .....
    }

    //-----------------------------------------------------------------------------
    // SLOT preferenceAct
    //-----------------------------------------------------------------------------
    void My_MainWindow::preferenceAct(void)
    {
    ui->prefDockWidget->show();
    }
    @

    I close prefDockWidget by the close button (X). How to use the event generated?
    I think I have to redefine the XXXX::CloseEvent(QCloseEvent *event) method that is called at this time.
    How to do this from the only info I have: ui-> prefDockWidget?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      QDockWidget has "toggleViewAction":http://qt-project.org/doc/qt-4.8/qdockwidget.html#toggleViewAction method which returns pointer to QAction.
      Then connect your slot to "QAction::toggled":http://qt-project.org/doc/qt-4.8/qaction.html#toggled When "checked" parameter is true, your dock widget is showed, else is closed

      1 Reply Last reply
      0
      • F Offline
        F Offline
        FRAUBRJ
        wrote on last edited by
        #3

        Thanks cincirin, it works perfectly!

        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