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. Adding QGroupBox around every item added

Adding QGroupBox around every item added

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 3 Posters 5.7k Views 3 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.
  • cerrC Offline
    cerrC Offline
    cerr
    wrote on last edited by
    #1

    Hi,

    I have a method that will add terminal windows in a splitter which works fine by itself but now I want to open each terminal window within a QGroupBox (in order to be able to display group member ship of each terminal).
    What I have tried is:

    QGroupBox *groupBox = new QGroupBox(tr("Test"));
    QWidget* terminalWidget = terminal->terminalWidget();
    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(terminalWidget);
    vbox->addStretch(1);
    groupBox->setLayout(vbox);
    if (groupBox) groupBox->setFocus();
    

    which I changed from:

    QWidget* terminalWidget = terminal->terminalWidget();
    if (terminalWidget) terminalWidget->setFocus();
    

    but what happens is, I see the groupBox but no terminal window within. Should thgat not be accomplished with the addWidget() call as per http://doc.qt.io/qt-4.8/qgroupbox.html - it says that the alignment isn't done automatically but I'm not even worried about that yet, I just want to see my terminal within the box. What am I missing?

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

      Hmm, it looks ok.
      You can try adding
      terminalWidget ->resize(100,100);
      terminalWidget ->show();
      To make sure its visible and have a size.

      cerrC 1 Reply Last reply
      1
      • mrjjM mrjj

        Hmm, it looks ok.
        You can try adding
        terminalWidget ->resize(100,100);
        terminalWidget ->show();
        To make sure its visible and have a size.

        cerrC Offline
        cerrC Offline
        cerr
        wrote on last edited by
        #3

        terminalWidget ->resize(100,100);
        terminalWidget ->show();

        I added this after groupBox->setLayout(vbox); but still don't see the terminal...

        I even copied the example from http://doc.qt.io/qt-4.8/qgroupbox.html but no radio buttons show up either....? My complete function now looks like:

        Terminal* Session::addTerminal(QWidget* parent)
        {
            Terminal* terminal = new Terminal(parent);
            connect(terminal, SIGNAL(activated(int)), this, SLOT(setActiveTerminal(int)));
            connect(terminal, SIGNAL(manuallyActivated(Terminal*)), this, SIGNAL(terminalManuallyActivated(Terminal*)));
            connect(terminal, SIGNAL(titleChanged(int,QString)), this, SLOT(setTitle(int,QString)));
            connect(terminal, SIGNAL(keyboardInputBlocked(Terminal*)), this, SIGNAL(keyboardInputBlocked(Terminal*)));
            connect(terminal, SIGNAL(silenceDetected(Terminal*)), this, SIGNAL(silenceDetected(Terminal*)));
            connect(terminal, SIGNAL(destroyed(int)), this, SLOT(cleanup(int)));
        
            m_terminals.insert(terminal->id(), terminal);    
            
            QGroupBox *groupBox = new QGroupBox(tr("Test"));
            QWidget* terminalWidget = terminal->terminalWidget();
            QVBoxLayout *vbox = new QVBoxLayout;
            QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
            QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
            QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
        
            radio1->setChecked(true);
        
            vbox->addWidget(radio1);
            vbox->addWidget(radio2);
            vbox->addWidget(radio3);
            
            vbox->addWidget(terminalWidget);
            vbox->addStretch(1);
            groupBox->setLayout(vbox);
            terminalWidget ->resize(100,100);
            terminalWidget ->show();    
            if (/*terminalWidget*/groupBox) /*terminalWidget*/groupBox->setFocus();
        
            return terminal;
        }
        

        All I see is: https://s12.postimg.org/z0sjkly71/screenshot1.jpg

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

          Hi,

          Are you showing the group box at any time ?

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

          cerrC 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            Are you showing the group box at any time ?

            cerrC Offline
            cerrC Offline
            cerr
            wrote on last edited by cerr
            #5

            @SGaist said in Adding QGroupBox around every item added:

            Hi,

            Are you showing the group box at any time ?

            I realize. as stupid as this may sound but that must be the problem - as the function (as above) returns the pointer to the terminal...i'll have to dig into this more...
            any chance I can draw someting on top or the terminal widget? (rather than making the terminal to be a member of something? I'm thinking of a top bar as seen in Terminator: https://i.kinja-img.com/gawker-media/image/upload/s--96aPzzem--/c_fit,fl_progressive,q_80,w_636/j5ktz8qa7rqrcs6wnxdy.jpg

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

              Looks like a MDI setup.

              QMdiArea
              QMdiSubWindow

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

              cerrC 1 Reply Last reply
              1
              • SGaistS SGaist

                Looks like a MDI setup.

                QMdiArea
                QMdiSubWindow

                cerrC Offline
                cerrC Offline
                cerr
                wrote on last edited by
                #7

                @SGaist
                We already have the terminal and the splitter and everything going but what I now would like to include is, that each split terminal can be added to a particular group so that key strokes can be sent to each terminal that is a member of that group instead of just to one.... and that's what I'm having troubles with.

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

                  Looks like you should rather use an event filter to propagate the key events to the other members of "terminal groups"

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

                  cerrC 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Looks like you should rather use an event filter to propagate the key events to the other members of "terminal groups"

                    cerrC Offline
                    cerrC Offline
                    cerr
                    wrote on last edited by
                    #9

                    @SGaist
                    I was intending to use the groupbox to display to group assignment for each terminal instance . Other ideas are appreciated, too!

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

                      That I understood, and it's one way to do it.

                      Out of curiosity, aren't you kind of re-implementing the Konsole application ?

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

                      cerrC 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        That I understood, and it's one way to do it.

                        Out of curiosity, aren't you kind of re-implementing the Konsole application ?

                        cerrC Offline
                        cerrC Offline
                        cerr
                        wrote on last edited by
                        #11

                        @SGaist
                        Konsole with some advanced features, see https://github.com/kterminal/kterminal

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

                          What features are you adding ?

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

                          cerrC 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            What features are you adding ?

                            cerrC Offline
                            cerrC Offline
                            cerr
                            wrote on last edited by
                            #13

                            @SGaist said in Adding QGroupBox around every item added:

                            What features are you adding ?

                            splitting (& grouping) kind of like in Terminator (https://launchpad.net/terminator).

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

                              Out of curiosity, why not improve Konsole directly ?

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

                              cerrC 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                Out of curiosity, why not improve Konsole directly ?

                                cerrC Offline
                                cerrC Offline
                                cerr
                                wrote on last edited by cerr
                                #15

                                @SGaist said in Adding QGroupBox around every item added:

                                Out of curiosity, why not improve Konsole directly ?

                                Because the splitting & tabbing the way it's done in Konsole is a particular feature that will be of benefit to a particular user base and we/I don't necessarily feel like messing with them as a newbie in terms of contributing to OSS - if that makes sense... I however could KTerminal see to become a second terminal option in (standard) KDE, next to Konsole for people that are looking for the other kind of tabbing & splitting...

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

                                  That's a wrong assumption you're doing. You should contact the Konsole maintainers and talk with them about this feature. That's the best way to know whether you should go ahead or provide an alternative.

                                  You seem to be a bit afraid of contributing. The best way to start is to talk with the people from the project and KDE is one very friendly project.

                                  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

                                  • Login

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