My main app window has a central QWidget consisting of a QGraphicsView and a QStackedWidget:
m_view= new saView(this);
m_stack->setMinimumWidth(256);
....
initWidgets();//this is the place where m_widgets[] holds the pointers of the new properties widgets
for(i=0;i<5;i++) {m_stack->addWidget(m_widgets[i]);};
splitter->setChildrenCollapsible(false);
splitter->addWidget(m_view);
splitter->addWidget(m_stack);
layout->addWidget(splitter);
setLayout(layout);
....
m_view= new saView(this);
m_stack=new QStackedWidget();
m_stack->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::MinimumExpanding);
m_stack->setMinimumWidth(256);
....
initWidgets();//this is the place where m_widgets[] holds the pointers of the new properties widgets
for(i=0;i<5;i++) {m_stack->addWidget(m_widgets[i]);};
QGridLayout *layout = new QGridLayout;//here I tried QHBoxLayout or QVBoxLayout but nothing....
QSplitter *splitter=new QSplitter(this);
splitter->setChildrenCollapsible(false);
splitter->addWidget(m_view);
splitter->addWidget(m_stack);
layout->addWidget(splitter);
setLayout(layout);
....
To copy to clipboard, switch view to plain text mode
The initWidgets() function :
void saGui::initWidgets()
{
//qDebug()<<"saGui::initWidgets";
int i;
//the 0 index is the empty properties window
//1 index is SteelNodeProperties window
saWidgetSteelNodeProperties* w=new saWidgetSteelNodeProperties(this);
m_widgets[1]=w;
...
...
// 2 index is ConcretePolygonProperties window
saWidgetConcretePolygonProperties* w2=new saWidgetConcretePolygonProperties(this);
m_widgets[2]=w2;
...
// 3 index is SteelLineProperties window
saWidgetSteelLineProperties* w3=new saWidgetSteelLineProperties(this);
m_widgets[3]=w3;
....
//4 index is the QWidget that contains the QGraphicsView that gets resized wrongfully
saWidgetMaterialProperties* w4=new saWidgetMaterialProperties(&m_materials,this);
m_widgets[4]=w4;//adding w4 to m_widgets produces the wrong size.
};
void saGui::initWidgets()
{
//qDebug()<<"saGui::initWidgets";
int i;
//the 0 index is the empty properties window
m_widgets[0]=new QWidget();
//1 index is SteelNodeProperties window
saWidgetSteelNodeProperties* w=new saWidgetSteelNodeProperties(this);
m_widgets[1]=w;
...
...
// 2 index is ConcretePolygonProperties window
saWidgetConcretePolygonProperties* w2=new saWidgetConcretePolygonProperties(this);
m_widgets[2]=w2;
...
// 3 index is SteelLineProperties window
saWidgetSteelLineProperties* w3=new saWidgetSteelLineProperties(this);
m_widgets[3]=w3;
....
//4 index is the QWidget that contains the QGraphicsView that gets resized wrongfully
saWidgetMaterialProperties* w4=new saWidgetMaterialProperties(&m_materials,this);
m_widgets[4]=w4;//adding w4 to m_widgets produces the wrong size.
};
To copy to clipboard, switch view to plain text mode
The QWidget is made inside Qt Designer. It has a QVBoxLayout, containing a QSplitter of a QGraphicsView, and a QStackedWidget , and a VerticalSpacer .
The file of the QWidget is here: WidgetMaterialProperties.ui.zip.
Notice that if I don't do :
scene->setSceneRect(....);
scene->setSceneRect(....);
To copy to clipboard, switch view to plain text mode
in my code , and just use the QGraphicsView/Scene adding items. the QGraphicsView starts with those sizes:
picQGinsize1.png
,that looks right but it is not. Because QGraphicsView has small height. And the vertical splitter between them cannot be moved. But If I put some items inside QGraphicsScene that are outsize active view the QGraphicsView starts to grows its size, growing also the mainApp window size and moving the window contents out of the screen .
Bookmarks