【问题标题】:QComboBox not aligning to rightQComboBox 未右对齐
【发布时间】:2020-12-14 06:07:50
【问题描述】:

我有一个QHBoxLayout,我想在右边添加一些孩子,在左边添加一些:

label = new QLabel(...);
layout->addItem(label);
layout->setAlignment(label, Qt::AlignLeft);
select = new QComboBox(...);
layout->addItem(select);
layout->setAlignment(select, Qt::AlignRight);

但是select 没有对齐到右边...有什么想法吗?

QCheckBoxQLabel 都不能使用,但使用 QSlider 可以正常工作

【问题讨论】:

    标签: c++ qt layout combobox


    【解决方案1】:
    QHBoxLayout * layout = new QHBoxLayout(this);
    QLabel * label = new QLabel("this is label");
    layout->addWidget(label, Qt::AlignLeft);
    layout->setAlignment(label, Qt::AlignLeft);
    QComboBox * select = new QComboBox(this);
    layout->addWidget(select);
    layout->setAlignment(select, Qt::AlignRight);
    

    【讨论】:

    • 谢谢,这是我的错,我在做layout->setAlignment(Qt::AlignLeft)
    猜你喜欢
    • 2018-09-25
    • 2019-10-25
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-18
    相关资源
    最近更新 更多