Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Another "reuse" question
QtWS25 Last Chance

Another "reuse" question

Scheduled Pinned Locked Moved Unsolved C++ Gurus
7 Posts 3 Posters 734 Views
  • 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
    Anonymous_Banned275
    wrote on 24 Mar 2024, 17:18 last edited by
    #1

    I have a working class declared as QPlainTextEdit.
    I like to add "status bar" and was looking to use multiple inheritance using QMainWindow.

    Coded as folloows I get an error

    /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/terminal_Bluetooth/console.h:79: warning: Class Console inherits from two QObject subclasses QPlainTextEdit and QMainWindow. This is not supported!

    What would be another logical way to add "status bar" to existing class ?

    I am asking this because
    "status bar" is part of the QMainWindow and there is no .ui file. It is "added " in code , passed to class. .

    #ifndef CONSOLE_H
    #define CONSOLE_H
    
    #include <QPlainTextEdit>
    #include <QMainWindow>
    
    class Console : public QPlainTextEdit, public QMainWindow
    {
        Q_OBJECT
    
    signals:
        void getData(const QByteArray &data);
    
    public:
        explicit Console(QWidget *parent = nullptr);
    
        void putData(const QByteArray &data);
        void setLocalEchoEnabled(bool set);
    
    protected:
        void keyPressEvent(QKeyEvent *e) override;
        void mousePressEvent(QMouseEvent *e) override;
        void mouseDoubleClickEvent(QMouseEvent *e) override;
        void contextMenuEvent(QContextMenuEvent *e) override;
    
    private:
        bool m_localEchoEnabled = false;
    };
    
    #endif // CONSOLE_H
    
    
    J 1 Reply Last reply 25 Mar 2024, 05:47
    0
    • A Anonymous_Banned275
      24 Mar 2024, 17:18

      I have a working class declared as QPlainTextEdit.
      I like to add "status bar" and was looking to use multiple inheritance using QMainWindow.

      Coded as folloows I get an error

      /mnt/A_BT_DEC10/BT__PROGRAMS/A_MAR7_MAR15/A_BT_LIBRARY/terminal_Bluetooth/console.h:79: warning: Class Console inherits from two QObject subclasses QPlainTextEdit and QMainWindow. This is not supported!

      What would be another logical way to add "status bar" to existing class ?

      I am asking this because
      "status bar" is part of the QMainWindow and there is no .ui file. It is "added " in code , passed to class. .

      #ifndef CONSOLE_H
      #define CONSOLE_H
      
      #include <QPlainTextEdit>
      #include <QMainWindow>
      
      class Console : public QPlainTextEdit, public QMainWindow
      {
          Q_OBJECT
      
      signals:
          void getData(const QByteArray &data);
      
      public:
          explicit Console(QWidget *parent = nullptr);
      
          void putData(const QByteArray &data);
          void setLocalEchoEnabled(bool set);
      
      protected:
          void keyPressEvent(QKeyEvent *e) override;
          void mousePressEvent(QMouseEvent *e) override;
          void mouseDoubleClickEvent(QMouseEvent *e) override;
          void contextMenuEvent(QContextMenuEvent *e) override;
      
      private:
          bool m_localEchoEnabled = false;
      };
      
      #endif // CONSOLE_H
      
      
      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 25 Mar 2024, 05:47 last edited by JKSH
      #2

      @AnneRanch said in Another "reuse" question:

      What would be another logical way to add "status bar" to existing class ?

      Add a QStatusBar to the bottom

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      A 1 Reply Last reply 10 Apr 2024, 15:58
      1
      • J JKSH
        25 Mar 2024, 05:47

        @AnneRanch said in Another "reuse" question:

        What would be another logical way to add "status bar" to existing class ?

        Add a QStatusBar to the bottom

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on 10 Apr 2024, 15:58 last edited by
        #3

        @JKSH OK, kindly allow me to "BUMP|".

        Here is the "Console" class declaration / definition.
        it is derived from QPlainTextEdit
        and has NO UI
        ( no Console.ui ! )

        It is NOT related to QMainWindow which has "status bar" as standard.

        This class / object is originally "embedded " in QMainWindow , actually in "mdiArea" which does have " status bar " .

        I need to have similar class which is no longer part of the original mdiArea, hence I need to add "status bar" to QPlainTextEdit

        QPlainTextEdit has "standard " widow title bar, but no status bar !

        I was hoping for "multiple inheritance " - adding QMainWindow , but it did not work!

        I believe QPlainTextEdit is derived from QWidget...

        Console::Console(QWidget *parent) :
            QPlainTextEdit(parent)
        {
            document()->setMaximumBlockCount(100);
            // font here ?? document()->set
            QPalette p = palette();
            // test chnage background color
            p.setColor(QPalette::Base, Qt::black);
            p.setColor(QPalette::Text, Qt::white);
        
            setPalette(p);
            //QStatusBar *pSB = new QStatusBar();
            text = " TEST status tip ..... ";
            setStatusTip(text);
            text = " Console display raw serial ASCII data...";
            setToolTip(text);
            //setstate(" TEST state ");
            //setState(text);
        
        }
        
        C 1 Reply Last reply 10 Apr 2024, 16:00
        0
        • A Anonymous_Banned275
          10 Apr 2024, 15:58

          @JKSH OK, kindly allow me to "BUMP|".

          Here is the "Console" class declaration / definition.
          it is derived from QPlainTextEdit
          and has NO UI
          ( no Console.ui ! )

          It is NOT related to QMainWindow which has "status bar" as standard.

          This class / object is originally "embedded " in QMainWindow , actually in "mdiArea" which does have " status bar " .

          I need to have similar class which is no longer part of the original mdiArea, hence I need to add "status bar" to QPlainTextEdit

          QPlainTextEdit has "standard " widow title bar, but no status bar !

          I was hoping for "multiple inheritance " - adding QMainWindow , but it did not work!

          I believe QPlainTextEdit is derived from QWidget...

          Console::Console(QWidget *parent) :
              QPlainTextEdit(parent)
          {
              document()->setMaximumBlockCount(100);
              // font here ?? document()->set
              QPalette p = palette();
              // test chnage background color
              p.setColor(QPalette::Base, Qt::black);
              p.setColor(QPalette::Text, Qt::white);
          
              setPalette(p);
              //QStatusBar *pSB = new QStatusBar();
              text = " TEST status tip ..... ";
              setStatusTip(text);
              text = " Console display raw serial ASCII data...";
              setToolTip(text);
              //setstate(" TEST state ");
              //setState(text);
          
          }
          
          C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 10 Apr 2024, 16:00 last edited by
          #4

          Simply build a new widget, add a layout and put the QPlainTextEdit and the status bar in there.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          A 1 Reply Last reply 11 Apr 2024, 00:03
          2
          • C Christian Ehrlicher
            10 Apr 2024, 16:00

            Simply build a new widget, add a layout and put the QPlainTextEdit and the status bar in there.

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on 11 Apr 2024, 00:03 last edited by
            #5

            @Christian-Ehrlicher ...and that is NOT what I expect from C++ " reuse " feature

            Here is yet another task.
            I can add messages / tool tip...

            Adding message into same class,
            not a member of the mdiArea,

            puts it in the middle of the form
            how do I move it to the bottom of the form - using code.?-

            Adding message into same class when it is a member of mdiAreaa subwidows puts the message
            into main mdiArea status bar when

            mouse hovers above the subwindow (status tip ?)

            Console::Console(QWidget *parent) :
                QPlainTextEdit(parent)
            {
                document()->setMaximumBlockCount(100);
                // font here ?? document()->set
                QPalette p = palette();
                // test change background color
                p.setColor(QPalette::Base, Qt::black);
                p.setColor(QPalette::Text, Qt::white);
            
                setPalette(p);
                //QStatusBar *pSB = new QStatusBar();
                text = " TEST status tip ..... (shows in mdiArea status bar ) ";
                setStatusTip(text);
            
            
            this is the only one which does as expected 
            
                text = " Console display raw serial ASCII data...";
                setToolTip(text);
            
              **this  message does not show anywhere** 
            
                QStatusBar *pTEST = new QStatusBar();
                pTEST->showMessage(" TEST status bar message ");
                pTEST->show();
            
            
            
            
            C J 2 Replies Last reply 11 Apr 2024, 04:19
            0
            • C Christian Ehrlicher referenced this topic on 11 Apr 2024, 04:18
            • A Anonymous_Banned275
              11 Apr 2024, 00:03

              @Christian-Ehrlicher ...and that is NOT what I expect from C++ " reuse " feature

              Here is yet another task.
              I can add messages / tool tip...

              Adding message into same class,
              not a member of the mdiArea,

              puts it in the middle of the form
              how do I move it to the bottom of the form - using code.?-

              Adding message into same class when it is a member of mdiAreaa subwidows puts the message
              into main mdiArea status bar when

              mouse hovers above the subwindow (status tip ?)

              Console::Console(QWidget *parent) :
                  QPlainTextEdit(parent)
              {
                  document()->setMaximumBlockCount(100);
                  // font here ?? document()->set
                  QPalette p = palette();
                  // test change background color
                  p.setColor(QPalette::Base, Qt::black);
                  p.setColor(QPalette::Text, Qt::white);
              
                  setPalette(p);
                  //QStatusBar *pSB = new QStatusBar();
                  text = " TEST status tip ..... (shows in mdiArea status bar ) ";
                  setStatusTip(text);
              
              
              this is the only one which does as expected 
              
                  text = " Console display raw serial ASCII data...";
                  setToolTip(text);
              
                **this  message does not show anywhere** 
              
                  QStatusBar *pTEST = new QStatusBar();
                  pTEST->showMessage(" TEST status bar message ");
                  pTEST->show();
              
              
              
              
              C Online
              C Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 11 Apr 2024, 04:19 last edited by
              #6

              @AnneRanch said in Another "reuse" question:

              and that is NOT what I expect from C++ " reuse " feature

              Then you should find another programming language or another tookit which does what you want instead.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1
              • A Anonymous_Banned275
                11 Apr 2024, 00:03

                @Christian-Ehrlicher ...and that is NOT what I expect from C++ " reuse " feature

                Here is yet another task.
                I can add messages / tool tip...

                Adding message into same class,
                not a member of the mdiArea,

                puts it in the middle of the form
                how do I move it to the bottom of the form - using code.?-

                Adding message into same class when it is a member of mdiAreaa subwidows puts the message
                into main mdiArea status bar when

                mouse hovers above the subwindow (status tip ?)

                Console::Console(QWidget *parent) :
                    QPlainTextEdit(parent)
                {
                    document()->setMaximumBlockCount(100);
                    // font here ?? document()->set
                    QPalette p = palette();
                    // test change background color
                    p.setColor(QPalette::Base, Qt::black);
                    p.setColor(QPalette::Text, Qt::white);
                
                    setPalette(p);
                    //QStatusBar *pSB = new QStatusBar();
                    text = " TEST status tip ..... (shows in mdiArea status bar ) ";
                    setStatusTip(text);
                
                
                this is the only one which does as expected 
                
                    text = " Console display raw serial ASCII data...";
                    setToolTip(text);
                
                  **this  message does not show anywhere** 
                
                    QStatusBar *pTEST = new QStatusBar();
                    pTEST->showMessage(" TEST status bar message ");
                    pTEST->show();
                
                
                
                
                J Offline
                J Offline
                JKSH
                Moderators
                wrote on 13 Apr 2024, 15:49 last edited by
                #7

                @AnneRanch said in Another "reuse" question:

                **this message does not show anywhere**

                auto pC = new Console; // Original class
                auto pSB = new QStatusBar; // Additional status bar
                
                auto layout = new QVBoxLayout;
                layout->addWidget(pC);
                layout->addWidget(pSB);
                
                auto consoleWithStatusBar = new QWidget;
                consoleWithStatusBar->setLayout(layout);
                consoleWithStatusBar->show();
                
                pSB->showMessage(" TEST status bar message ");
                

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • C Christian Ehrlicher referenced this topic on 13 Apr 2024, 16:56
                • C Christian Ehrlicher referenced this topic on 14 Apr 2024, 18:37

                • Login

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