Here is what happens in a typical case with my current code: it works for 2 or 3, but obscures one (I'll worry about the giant set button later...ha ha). When I think about it, it makes sense; factoring in the top area makes all the difference:
one.jpgtwo.pngthree.png
As for the constructor, it is like this. The m_nodeLabel is set by a different function called after construction:
18 NodeEditBox
::NodeEditBox(QWidget* _parent, vector<string> _sliderLabels
){ 19
20 resize(450, 90*(_sliderLabels.size()));
21 setWindowTitle("Modify Node");
22
24
25 m_nodeLabel
= new QLabel(this);
26 m_nodeLabel
->setGeometry
(QRect(10,
10,
67,
21));
27 m_layout->addWidget(m_nodeLabel);
28
29 for(size_t i = 0; i < _sliderLabels.size(); i++){
30 NodeEditSlider* s = new NodeEditSlider(this, _sliderLabels[i]);
31 m_sliders.push_back(s);
32 m_layout->addWidget(s);
33 }
34
36 m_setButton->setText("Set");
37 m_layout->addWidget(m_setButton);
38
39 this->setLayout(m_layout);
40 }
18 NodeEditBox::NodeEditBox(QWidget* _parent, vector<string> _sliderLabels){
19
20 resize(450, 90*(_sliderLabels.size()));
21 setWindowTitle("Modify Node");
22
23 m_layout = new QVBoxLayout();
24
25 m_nodeLabel = new QLabel(this);
26 m_nodeLabel->setGeometry(QRect(10, 10, 67, 21));
27 m_layout->addWidget(m_nodeLabel);
28
29 for(size_t i = 0; i < _sliderLabels.size(); i++){
30 NodeEditSlider* s = new NodeEditSlider(this, _sliderLabels[i]);
31 m_sliders.push_back(s);
32 m_layout->addWidget(s);
33 }
34
35 m_setButton = new QPushButton(this);
36 m_setButton->setText("Set");
37 m_layout->addWidget(m_setButton);
38
39 this->setLayout(m_layout);
40 }
To copy to clipboard, switch view to plain text mode
Here is the NodeEditSlider widget constructor. I made it on the QtDesigner and then pasted the code into my program and modified it as needed (removing retranslate UI business, etc...) :
3 NodeEditSlider
::NodeEditSlider(QWidget* _parent, string _label
){ 4
6 m_slider
->setGeometry
(QRect(50,
10,
371,
20));
7 m_slider->setOrientation(Qt::Horizontal);
8
10 m_label
->setGeometry
(QRect(10,
10,
41,
21));
11
13 m_label->setText(label);
14
15 }
3 NodeEditSlider::NodeEditSlider(QWidget* _parent, string _label){
4
5 m_slider = new QSlider(this);
6 m_slider->setGeometry(QRect(50, 10, 371, 20));
7 m_slider->setOrientation(Qt::Horizontal);
8
9 m_label = new QLabel(this);
10 m_label->setGeometry(QRect(10, 10, 41, 21));
11
12 QString label = QString::fromStdString(_label);
13 m_label->setText(label);
14
15 }
To copy to clipboard, switch view to plain text mode
Added after 1 48 minutes:
Bookmarks