QTextEdit太大?

发布于 2024-10-03 14:29:25 字数 983 浏览 0 评论 0原文

我不明白为什么我的 QTextEdit 这么大,尽管我没有拉伸就插入了它。我只想让它成为一行。

    self.widget = QWidget()
    vbox = QVBoxLayout()
    vbox.addWidget(self.ppd_widget, 1)  # this widget is big, and I'm pretty sure it stretches. 

    hbox = QHBoxLayout()
    vbox.addLayout(hbox, 0)

    self.n_button = QPushButton("&New training example")
    self.connect(self.n_button, SIGNAL('clicked()'), self.on_new_example)
    self.i_button = QPushButton("&Infer")
    self.connect(self.i_button, SIGNAL('clicked()'), self.on_infer)
    self.t_button = QPushButton("&Train")
    self.connect(self.t_button, SIGNAL('clicked()'), self.on_train)

    hbox.addWidget(QLabel("Training example: "), 0)
    self.example_number = QTextEdit()
    self.example_number.setLineWrapMode(0)#QPlainTextEdit.NoWrap)
    hbox.addWidget(self.example_number, 0)

    hbox.addWidget(self.n_button, 0)
    hbox.addWidget(self.i_button, 0)
    hbox.addWidget(self.t_button, 0)
    hbox.addSpacing(1)

I can't figure out why my QTextEdit is so big despite my having inserted it without stretch. I just want it to be one line.

    self.widget = QWidget()
    vbox = QVBoxLayout()
    vbox.addWidget(self.ppd_widget, 1)  # this widget is big, and I'm pretty sure it stretches. 

    hbox = QHBoxLayout()
    vbox.addLayout(hbox, 0)

    self.n_button = QPushButton("&New training example")
    self.connect(self.n_button, SIGNAL('clicked()'), self.on_new_example)
    self.i_button = QPushButton("&Infer")
    self.connect(self.i_button, SIGNAL('clicked()'), self.on_infer)
    self.t_button = QPushButton("&Train")
    self.connect(self.t_button, SIGNAL('clicked()'), self.on_train)

    hbox.addWidget(QLabel("Training example: "), 0)
    self.example_number = QTextEdit()
    self.example_number.setLineWrapMode(0)#QPlainTextEdit.NoWrap)
    hbox.addWidget(self.example_number, 0)

    hbox.addWidget(self.n_button, 0)
    hbox.addWidget(self.i_button, 0)
    hbox.addWidget(self.t_button, 0)
    hbox.addSpacing(1)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罗罗贝儿 2024-10-10 14:29:25

如果您只想要一行,您应该使用 QLineEdit。您的按钮有首选大小策略,使它们保持固定大小。 QTextEdit 可能具有MinimumExpanding 或Expanding,因此占用了剩余的可用空间。

If you want one line only, you should use QLineEdit. Your buttons have Preferred size policy, which keeps them at a fixes size. The QTextEdit probably has MinimumExpanding or Expanding, and thus takes up the rest of the available space.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文