QT中怎么设置QTextEdit和QHBoxLayout初始大小呢?

QT中怎么设置QTextEdit和QHBoxLayout初始大小呢?,第1张

resize()函数是有用的

QTextEdit textEdit

textEdit.resize(100,22)

QHBoxLayout * layout = new QHBoxLayout

layout->addWidget(&textEdit)

最后不要忘了在某处调用setLayout()这个函数,需要视布局而定

1.试试 把 按钮背景(就是那个黑色的方块,一般在SystemUI 的 res/drawable-mdpi里面),用 PS或者美图秀秀修改尺寸,把,宽度 变窄一点。

2.如果 本身的源码布局就是 两行的话,就得改源码了。

要改的有以下几个方面:所有的 按钮都在同一个水平 布局上<LinearLayout android:orientation="horizontal"把其他的<LinearLayout 删掉(要保留button的代码部分),再定义每个 button的android:layout_weight="1.0"(参考blog.csdn.net/yanglian20009/article/details/7205785)

多说几句,我感觉你的UI还是可以忍受的,虽然我的ROM 可以自定义 按钮的个数,呵呵。还有什么问题追问哦。

再说几句,你想改这个是需要修改系统软件SystemUI.apk的 搞不好替换后就通知栏FC了。(所以提前做好recovery备份),还有系统apk的权限都是 读写读读。

//程序抽象类

#include <QApplication>

//窗口类

#include <QWidget>

#include <QPushButton>

#include <QLineEdit>

//自动竖版布局

#include <QVBoxLayout>

//自动横版布局

#include <QHBoxLayout>

//自动格子布局

#include <QGridLayout>

int main(int argc, char* argv[])

{

    QApplication app(argc, argv)

    QWidget w

    //按钮也是一个窗口

    QPushButton button

    button.setText("你好")

    //button.setParent(&w)

    button.show()

    //输入框也是一个窗口

    QLineEdit editor

    editor.setEchoMode(QLineEdit::Normal)

    editor.setPlaceholderText("请输入文本")

    //editor.setParent(&w)

    editor.show()

    //水平方向上的layout

    //QVBoxLayout vBox

    //vBox.addWidget(&button)

    //vBox.addWidget(&editor)

    //垂直方向上的layout

    QHBoxLayout hBox

    //设置左右d簧 使得控件大小不随窗口改变

    hBox.addStretch(1)

    hBox.addWidget(&button,1)

    //设置两个空间的间距为20

    hBox.addSpacing(20)

    hBox.addWidget(&editor,1)

    hBox.addStretch(1)

    w.setWindowTitle("hello world")

    w.show()

    w.setLayout(&hBox)

    return app.exec()

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/tougao/7861245.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-10
下一篇 2023-04-10

发表评论

登录后才能评论

评论列表(0条)

保存