Solved Adding QGroupBox around every item added
-
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?
-
Hmm, it looks ok.
You can try adding
terminalWidget ->resize(100,100);
terminalWidget ->show();
To make sure its visible and have a size. -
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
-
Hi,
Are you showing the group box at any time ?
-
@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 -
Looks like a MDI setup.
-
@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. -
Looks like you should rather use an event filter to propagate the key events to the other members of "terminal groups"
-
@SGaist
I was intending to use the groupbox to display to group assignment for each terminal instance . Other ideas are appreciated, too! -
That I understood, and it's one way to do it.
Out of curiosity, aren't you kind of re-implementing the Konsole application ?
-
@SGaist
Konsole with some advanced features, see https://github.com/kterminal/kterminal -
What features are you adding ?
-
@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).
-
Out of curiosity, why not improve Konsole directly ?
-
@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...
-
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.