c++ - 在 QHBoxlayout 之间设置线

标签 c++ qt

我想在我的表单中绘制一条水平和垂直的线,我使用QVBoxlayoutQHBoxLayout来显示我的小部件,但我没有不知道如何画线?我试过这个:

QLine *myline = new QLine(m_progress_part->geometry().bottomLeft(), m_main_page->geometry().bottomRight());

但什么也没有出现

我想要这个表格: 1

但我的表格就像第二个:

enter image description here

最佳答案

QLine 不是您可以在小部件上绘制的东西 - 它只是一个二维 vector (几何)。 为了在您的 GUI 中绘制或放置看起来像一条线的东西,我会执行以下操作:

QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine); // Horizontal line
line->setFrameShadow(QFrame::Sunken);
line->setLineWidth(1);

// Now add the line to the layout.
QVBoxLayout *mainLayout = new QVBoxLayout;
[..]
mainLayout->addWidget(line);

关于c++ - 在 QHBoxlayout 之间设置线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23079122/

相关文章:

c++ - 具有不同值的指针成员变量

Qt WebKit 打印收缩系数

Qt 5.4-QT_MESSAGELOGCONTEXT

c++ - 静态变量初始化顺序

c++ - 从 DirectShow 过滤器向属性页发送消息

c++ - WriteFile 函数 C++

C++ - 调用的 Lua 函数总是返回 0

c++ - x,y,z 点的 vtk 值

c++ - 存储在 vector 中的图像都是相同的

qt - Qt中如何获取滚动条的实际宽度?