LoginSignup
0
1

More than 5 years have passed since last update.

Qtアプリでステータスバーに長いテキストを設定するとメインウィンドウの幅が広がる問題(PySide版)

Last updated at Posted at 2017-06-21

はじめに

このtipsは以下と同じ問題をPySideで解決する場合のやり方だよ!
http://qiita.com/soramimi_jp/items/3d4e800e3d86ed216deb

たいさく

PySideで強制的に広がらないクラスを作りましょう。

StatusLabel.py

# -*- coding: utf-8 -*-
from PySide import QtGui
class StatusLabel(QtGui.QLabel):

    def __init__(self,parent=None):
        super(StatusLabel,self).__init__(parent)

    def minimumSizeHint(self):
        sz = QtGui.QLabel.minimumSizeHint(self)
        sz.setWidth(0)
        return sz

mainwindowでいい感じに使いましょう。

mainwindow.py
# -*- coding: utf-8 -*-
from StatusLabel import StatusLabel
class MainWindow(QtGui.QMainWindow,Ui_MainWindow):

    def __init__(self, parent=None):

        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.statuslabel = StatusLabel("a long text......")
        self.statusBar.addWidget(self.statuslabel)

おしまい。

どうでもいいけどC(++)とPython行ったり来たりするの辛いヨ。。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1