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. QPlainTextEdit::QCloseEvent
Forum Updated to NodeBB v4.3 + New Features

QPlainTextEdit::QCloseEvent

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.4k Views 2 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.
  • M Offline
    M Offline
    Mehodin
    wrote on last edited by
    #5

    @mrjj do you maybe know a different way to just clear() it when it closes?

    mrjjM 1 Reply Last reply
    0
    • M Mehodin

      @mrjj do you maybe know a different way to just clear() it when it closes?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @Mehodin
      Hi
      When its a window, then close Event seems pretty appropriate if you want to perform
      some task when extra floating window is closed.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Mehodin
        wrote on last edited by
        #7

        @mrjj yeah but it's not a real QWindow, it's just a widget that's floating.

        mrjjM 1 Reply Last reply
        0
        • M Mehodin

          @mrjj yeah but it's not a real QWindow, it's just a widget that's floating.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #8

          @Mehodin
          Hi
          Well any widget, you dont give a parent, will set the Be a Window flags and
          act like a window with border etc. So using closeEvent seems fine
          to do some last call clean up when its closed.
          Only downside is that you have to subclass QPlainTextEdit to have access to it.

          But since you want to call something in Firefly , you might want to do something like

          #ifndef MYPLAINTEXT_H
          #define MYPLAINTEXT_H
          
          #include <QPlainTextEdit>
          
          class MyPlainText : public QPlainTextEdit
          {
              Q_OBJECT
          public:
              explicit MyPlainText(QWidget *parent = nullptr) : QPlainTextEdit(parent) {}
          signals:
              void Closing(); // define new signal
          
          protected:
              virtual void closeEvent(QCloseEvent *event) override
              {
                  emit Closing(); // send signal before closing.
                  QPlainTextEdit::closeEvent(event);
              }
          };
          
          #endif // MYPLAINTEXT_H
          

          and hook the new signal Closing to Firefly::clearSubMenus
          from outside. That way, MyPlainText dont need any access to Firefly.

          1 Reply Last reply
          4
          • M Offline
            M Offline
            Mehodin
            wrote on last edited by
            #9

            @mrjj

            0_1550599921743_d9a3530b-c89c-4b14-b500-562040496230-afbeelding.png

            That's somehow giving me a lot of errors though when using it.

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #10

              Hi
              Hmm. compiles here.
              How did you use it ?
              should be placed in its own .h file and included in the project.
              Then you hook up new signal and show the widget.

              void MainWindow::on_pushButton_clicked()
              {
                  auto *win = new MyPlainText();
                  win->setAttribute(Qt::WA_DeleteOnClose);
                  connect(win, &MyPlainText::Closing, this, []() {
                      qDebug() << "win is closing";
                  });
              
                  win->show();
              }
              
              

              test project
              https://www.dropbox.com/s/hg8xz8uour34cc8/untitled79.zip?dl=0

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mehodin
                wrote on last edited by
                #11

                #ifndef MYPLAINTEXT_H
                #define MYPLAINTEXT_H

                #include <QPlainTextEdit>

                class textWindow : public QPlainTextEdit
                {
                Q_OBJECT
                public:
                explicit textWindow(QWidget *parent = nullptr) : QPlainTextEdit(parent) {}
                signals:
                void Closing(); // define new signal

                protected:
                virtual void closeEvent(QCloseEvent *event) override
                {
                emit Closing(); // send signal before closing.
                QPlainTextEdit::closeEvent(event);
                }
                };
                #endif

                in a .h file

                proxyText = new textWindow();
                configText = new textWindow();
                comboText = new textWindow();
                connect(proxyText, &textWindow::Closing, this, &Firefly::clearSubMenus);
                //connect(configText, &textWindow::Closing, this, &Firefly::clearSubMenus);
                //connect(comboText, &textWindow::Closing, this, &Firefly::clearSubMenus);
                

                in firefly.cpp

                @mrjj

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  Hi,

                  What does clearSubMenus look like ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mehodin
                    wrote on last edited by
                    #13

                    @SGaist

                    The 3 text edits ->clear(); (on phone right now)

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      I meant it signature.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1

                      • Login

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