void DisplayPathFilename::mainlayout() { m_hboxlayout->addWidget(m_filenamelabel); m_filenamelabel->setText("配置文件:"); m_hboxlayout->addWidget(m_filenamelineedit); m_hboxlayout->addWidget(m_displaypathlabel); m_displaypathlabel->setText("配置文件路径:"); m_hboxlayout->addWidget(m_displaypathlineedit); m_hboxlayout->setContentsMargins(0,0,0,3); m_hboxlayout->setStretch(0,0); //设置比例,根据前面添加到布局中的控件的顺序,通过索引设置比例 m_hboxlayout->setStretch(1,1); m_hboxlayout->setStretch(2,0); m_hboxlayout->setStretch(3,2); }
效果:
标签:控件,layout,qt,配置文件,hboxlayout,设置,addWidget,setStretch From: https://www.cnblogs.com/RedWetPlace/p/17355921.html