2012-09-19 52 views
2

當我創造出了主窗口與dockWidget一個Python測試程序(Test_InfoPanel.py)滾動條不scrollarea顯示,並在其中,與scrollArea小部件tabWidget。 然而,當我調整主窗口,垂直滾動條沒有自動出現時PyQt4中:調整dockWidget

同樣地,當我取消停靠dockWidget &調整大小,垂直滾動條不會自動出現。

請幫忙!

測試程序(Test_InfoPanel.py):

#!/usr/bin/env python 

# Filename: Test_InfoPanel.py 
# Date: 2012-Sep-18 
''' 
This program test the scrollarea to show scrollbars for the InfoPanel_UI. 
''' 

import sys 
from PyQt4 import QtCore, QtGui 

if __name__ == "__main__": 
    import sys 
    app = QtGui.QApplication(sys.argv) 
    # Look and feel changed to 'Cleanlooks'. 
    app.setStyle('Cleanlooks') 

    from InfoPanel_UI import Ui_MainWindow_InfoPanel 

    AppWindow = QtGui.QMainWindow() 
    ui = Ui_MainWindow_InfoPanel() 
    ui.setupUi(AppWindow) 

    ui.tabWidget_Info_Panel.setCurrentWidget(ui.scrollArea_Info_Panel) 

    AppWindow.show() 
    sys.exit(app.exec_()) 

生成*的.ui腳本(InfoPanel_UI.py):

# -*- coding: utf-8 -*- 

# Form implementation generated from reading ui file 'InfoPanel.ui' 
# 
# Created: Wed Sep 19 13:11:06 2012 
#  by: PyQt4 UI code generator 4.9.4 
# 
# WARNING! All changes made in this file will be lost! 

from PyQt4 import QtCore, QtGui 

try: 
    _fromUtf8 = QtCore.QString.fromUtf8 
except AttributeError: 
    _fromUtf8 = lambda s: s 

class Ui_MainWindow_InfoPanel(object): 
    def setupUi(self, MainWindow_InfoPanel): 
     MainWindow_InfoPanel.setObjectName(_fromUtf8("MainWindow_InfoPanel")) 
     MainWindow_InfoPanel.resize(602, 263) 
     MainWindow_InfoPanel.setDocumentMode(False) 
     self.centralwidget = QtGui.QWidget(MainWindow_InfoPanel) 
     self.centralwidget.setObjectName(_fromUtf8("centralwidget")) 
     MainWindow_InfoPanel.setCentralWidget(self.centralwidget) 
     self.statusbar = QtGui.QStatusBar(MainWindow_InfoPanel) 
     self.statusbar.setObjectName(_fromUtf8("statusbar")) 
     MainWindow_InfoPanel.setStatusBar(self.statusbar) 
     self.dockWidget_Info_Panel = QtGui.QDockWidget(MainWindow_InfoPanel) 
     self.dockWidget_Info_Panel.setMinimumSize(QtCore.QSize(300, 140)) 
     font = QtGui.QFont() 
     font.setBold(True) 
     font.setItalic(True) 
     font.setWeight(75) 
     self.dockWidget_Info_Panel.setFont(font) 
     self.dockWidget_Info_Panel.setLayoutDirection(QtCore.Qt.LeftToRight) 
     self.dockWidget_Info_Panel.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) 
     self.dockWidget_Info_Panel.setObjectName(_fromUtf8("dockWidget_Info_Panel")) 
     self.dockWidgetContents_Info_Panel = QtGui.QWidget() 
     self.dockWidgetContents_Info_Panel.setObjectName(_fromUtf8("dockWidgetContents_Info_Panel")) 
     self.tabWidget_Info_Panel = QtGui.QTabWidget(self.dockWidgetContents_Info_Panel) 
     self.tabWidget_Info_Panel.setGeometry(QtCore.QRect(0, 0, 300, 215)) 
     font = QtGui.QFont() 
     font.setBold(False) 
     font.setItalic(False) 
     font.setWeight(50) 
     self.tabWidget_Info_Panel.setFont(font) 
     self.tabWidget_Info_Panel.setObjectName(_fromUtf8("tabWidget_Info_Panel")) 
     self.tab_1 = QtGui.QWidget() 
     self.tab_1.setObjectName(_fromUtf8("tab_1")) 
     self.scrollArea_Info_Panel = QtGui.QScrollArea(self.tab_1) 
     self.scrollArea_Info_Panel.setGeometry(QtCore.QRect(9, 9, 271, 171)) 
     self.scrollArea_Info_Panel.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) 
     self.scrollArea_Info_Panel.setWidgetResizable(True) 
     self.scrollArea_Info_Panel.setObjectName(_fromUtf8("scrollArea_Info_Panel")) 
     self.scrollAreaWidgetContents = QtGui.QWidget() 
     self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 269, 169)) 
     self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents")) 
     self.frame_Info_Panel = QtGui.QFrame(self.scrollAreaWidgetContents) 
     self.frame_Info_Panel.setGeometry(QtCore.QRect(0, 0, 261, 161)) 
     self.frame_Info_Panel.setObjectName(_fromUtf8("frame_Info_Panel")) 
     self.label_Eqpt_Model = QtGui.QLabel(self.frame_Info_Panel) 
     self.label_Eqpt_Model.setGeometry(QtCore.QRect(10, 10, 111, 27)) 
     self.label_Eqpt_Model.setObjectName(_fromUtf8("label_Eqpt_Model")) 
     self.lineEdit_Eqpt_Model = QtGui.QLineEdit(self.frame_Info_Panel) 
     self.lineEdit_Eqpt_Model.setEnabled(False) 
     self.lineEdit_Eqpt_Model.setGeometry(QtCore.QRect(120, 10, 111, 27)) 
     palette = QtGui.QPalette() 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) 
     self.lineEdit_Eqpt_Model.setPalette(palette) 
     self.lineEdit_Eqpt_Model.setObjectName(_fromUtf8("lineEdit_Eqpt_Model")) 
     self.label_State = QtGui.QLabel(self.frame_Info_Panel) 
     self.label_State.setGeometry(QtCore.QRect(10, 40, 111, 27)) 
     self.label_State.setObjectName(_fromUtf8("label_State")) 
     self.lineEdit_State = QtGui.QLineEdit(self.frame_Info_Panel) 
     self.lineEdit_State.setEnabled(False) 
     self.lineEdit_State.setGeometry(QtCore.QRect(120, 40, 111, 27)) 
     palette = QtGui.QPalette() 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) 
     self.lineEdit_State.setPalette(palette) 
     self.lineEdit_State.setObjectName(_fromUtf8("lineEdit_State")) 
     self.groupBox_Current_Position = QtGui.QGroupBox(self.frame_Info_Panel) 
     self.groupBox_Current_Position.setGeometry(QtCore.QRect(10, 70, 241, 91)) 
     palette = QtGui.QPalette() 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) 
     brush = QtGui.QBrush(QtGui.QColor(170, 255, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) 
     brush = QtGui.QBrush(QtGui.QColor(127, 255, 63)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) 
     brush = QtGui.QBrush(QtGui.QColor(42, 127, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) 
     brush = QtGui.QBrush(QtGui.QColor(56, 170, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) 
     brush = QtGui.QBrush(QtGui.QColor(170, 255, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) 
     brush = QtGui.QBrush(QtGui.QColor(170, 255, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) 
     brush = QtGui.QBrush(QtGui.QColor(127, 255, 63)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) 
     brush = QtGui.QBrush(QtGui.QColor(42, 127, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) 
     brush = QtGui.QBrush(QtGui.QColor(56, 170, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) 
     brush = QtGui.QBrush(QtGui.QColor(170, 255, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(42, 127, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) 
     brush = QtGui.QBrush(QtGui.QColor(170, 255, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) 
     brush = QtGui.QBrush(QtGui.QColor(127, 255, 63)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) 
     brush = QtGui.QBrush(QtGui.QColor(42, 127, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) 
     brush = QtGui.QBrush(QtGui.QColor(56, 170, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) 
     brush = QtGui.QBrush(QtGui.QColor(42, 127, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(42, 127, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) 
     brush = QtGui.QBrush(QtGui.QColor(85, 255, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) 
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) 
     self.groupBox_Current_Position.setPalette(palette) 
     self.groupBox_Current_Position.setObjectName(_fromUtf8("groupBox_Current_Position")) 
     self.label_Current_Position_X = QtGui.QLabel(self.groupBox_Current_Position) 
     self.label_Current_Position_X.setGeometry(QtCore.QRect(20, 20, 41, 27)) 
     self.label_Current_Position_X.setObjectName(_fromUtf8("label_Current_Position_X")) 
     self.lineEdit_Current_Position_X = QtGui.QLineEdit(self.groupBox_Current_Position) 
     self.lineEdit_Current_Position_X.setEnabled(False) 
     self.lineEdit_Current_Position_X.setGeometry(QtCore.QRect(60, 20, 161, 27)) 
     palette = QtGui.QPalette() 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) 
     self.lineEdit_Current_Position_X.setPalette(palette) 
     self.lineEdit_Current_Position_X.setObjectName(_fromUtf8("lineEdit_Current_Position_X")) 
     self.label_Current_Position_Y = QtGui.QLabel(self.groupBox_Current_Position) 
     self.label_Current_Position_Y.setGeometry(QtCore.QRect(20, 50, 41, 27)) 
     self.label_Current_Position_Y.setObjectName(_fromUtf8("label_Current_Position_Y")) 
     self.lineEdit_Current_Position_Y = QtGui.QLineEdit(self.groupBox_Current_Position) 
     self.lineEdit_Current_Position_Y.setEnabled(False) 
     self.lineEdit_Current_Position_Y.setGeometry(QtCore.QRect(60, 50, 161, 27)) 
     palette = QtGui.QPalette() 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(60, 60, 60)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) 
     brush = QtGui.QBrush(QtGui.QColor(0, 0, 127)) 
     brush.setStyle(QtCore.Qt.SolidPattern) 
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) 
     self.lineEdit_Current_Position_Y.setPalette(palette) 
     self.lineEdit_Current_Position_Y.setObjectName(_fromUtf8("lineEdit_Current_Position_Y")) 
     self.scrollArea_Info_Panel.setWidget(self.scrollAreaWidgetContents) 
     self.tabWidget_Info_Panel.addTab(self.tab_1, _fromUtf8("")) 
     self.tab_2 = QtGui.QWidget() 
     self.tab_2.setObjectName(_fromUtf8("tab_2")) 
     self.tabWidget_Info_Panel.addTab(self.tab_2, _fromUtf8("")) 
     self.dockWidget_Info_Panel.setWidget(self.dockWidgetContents_Info_Panel) 
     MainWindow_InfoPanel.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockWidget_Info_Panel) 

     self.retranslateUi(MainWindow_InfoPanel) 
     self.tabWidget_Info_Panel.setCurrentIndex(0) 
     QtCore.QMetaObject.connectSlotsByName(MainWindow_InfoPanel) 

    def retranslateUi(self, MainWindow_InfoPanel): 
     MainWindow_InfoPanel.setWindowTitle(QtGui.QApplication.translate("MainWindow_InfoPanel", "MainWindow Info Panel", None, QtGui.QApplication.UnicodeUTF8)) 
     self.dockWidget_Info_Panel.setWindowTitle(QtGui.QApplication.translate("MainWindow_InfoPanel", "Info Panel", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_Eqpt_Model.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "Eqpt Model:", None, QtGui.QApplication.UnicodeUTF8)) 
     self.lineEdit_Eqpt_Model.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "ABC", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_State.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "State:", None, QtGui.QApplication.UnicodeUTF8)) 
     self.lineEdit_State.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "Working", None, QtGui.QApplication.UnicodeUTF8)) 
     self.groupBox_Current_Position.setTitle(QtGui.QApplication.translate("MainWindow_InfoPanel", "Current Position:", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_Current_Position_X.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "X =", None, QtGui.QApplication.UnicodeUTF8)) 
     self.lineEdit_Current_Position_X.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "1000.00 m", None, QtGui.QApplication.UnicodeUTF8)) 
     self.label_Current_Position_Y.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "Y =", None, QtGui.QApplication.UnicodeUTF8)) 
     self.lineEdit_Current_Position_Y.setText(QtGui.QApplication.translate("MainWindow_InfoPanel", "1000.00 m", None, QtGui.QApplication.UnicodeUTF8)) 
     self.tabWidget_Info_Panel.setTabText(self.tabWidget_Info_Panel.indexOf(self.tab_1), QtGui.QApplication.translate("MainWindow_InfoPanel", "Info_Pg 1", None, QtGui.QApplication.UnicodeUTF8)) 
     self.tabWidget_Info_Panel.setTabText(self.tabWidget_Info_Panel.indexOf(self.tab_2), QtGui.QApplication.translate("MainWindow_InfoPanel", "Info_Pg 2", None, QtGui.QApplication.UnicodeUTF8)) 

PS:我啓動盟友創建了一個對話框的主窗口,但意識到,在取消鎖定&重新鎖定後,dockWidget無法正確對接。不知何故有一個抵消。如果mainWindow是QtGui.QMainWindow而不是QtGui.QDialog,這似乎不成問題。

回答

0

您不必在ui文件中的任何佈局。不要只把小部件放在某些位置上。使用適當的佈局來放置您的小部件。佈局將確保小部件在調整大小時適當地增長/收縮。

官方文檔包含using layouts in Qt Designer的章節。

編輯

樣品ui文件,顯示正確使用佈局:

<?xml version="1.0" encoding="UTF-8"?> 
<ui version="4.0"> 
<class>MainWindow</class> 
<widget class="QMainWindow" name="MainWindow"> 
    <property name="geometry"> 
    <rect> 
    <x>0</x> 
    <y>0</y> 
    <width>539</width> 
    <height>600</height> 
    </rect> 
    </property> 
    <property name="windowTitle"> 
    <string>MainWindow</string> 
    </property> 
    <widget class="QWidget" name="centralwidget"> 
    <layout class="QGridLayout" name="gridLayout"> 
    <item row="0" column="0"> 
    <widget class="QFrame" name="frame"> 
     <property name="frameShape"> 
     <enum>QFrame::StyledPanel</enum> 
     </property> 
     <property name="frameShadow"> 
     <enum>QFrame::Raised</enum> 
     </property> 
    </widget> 
    </item> 
    </layout> 
    </widget> 
    <widget class="QMenuBar" name="menubar"> 
    <property name="geometry"> 
    <rect> 
    <x>0</x> 
    <y>0</y> 
    <width>539</width> 
    <height>21</height> 
    </rect> 
    </property> 
    </widget> 
    <widget class="QStatusBar" name="statusbar"/> 
    <widget class="QDockWidget" name="dockWidget_2"> 
    <attribute name="dockWidgetArea"> 
    <number>2</number> 
    </attribute> 
    <widget class="QWidget" name="dockWidgetContents_2"> 
    <layout class="QVBoxLayout" name="verticalLayout_2"> 
    <item> 
     <widget class="QTabWidget" name="tabWidget"> 
     <widget class="QWidget" name="tab"> 
     <attribute name="title"> 
     <string>Tab 1</string> 
     </attribute> 
     <layout class="QVBoxLayout" name="verticalLayout"> 
     <item> 
      <widget class="QScrollArea" name="scrollArea"> 
      <property name="widgetResizable"> 
      <bool>true</bool> 
      </property> 
      <widget class="QWidget" name="scrollAreaWidgetContents"> 
      <property name="geometry"> 
      <rect> 
       <x>0</x> 
       <y>0</y> 
       <width>327</width> 
       <height>473</height> 
      </rect> 
      </property> 
      <layout class="QGridLayout" name="gridLayout_2"> 
      <item row="4" column="1"> 
       <widget class="QLineEdit" name="lineEdit_4"/> 
      </item> 
      <item row="3" column="1"> 
       <widget class="QLineEdit" name="lineEdit_3"/> 
      </item> 
      <item row="0" column="0"> 
       <widget class="QLabel" name="label"> 
       <property name="text"> 
       <string>Eqpt Model:</string> 
       </property> 
       </widget> 
      </item> 
      <item row="4" column="0"> 
       <widget class="QLabel" name="label_5"> 
       <property name="text"> 
       <string>Y=</string> 
       </property> 
       </widget> 
      </item> 
      <item row="1" column="0"> 
       <widget class="QLabel" name="label_2"> 
       <property name="text"> 
       <string>State:</string> 
       </property> 
       </widget> 
      </item> 
      <item row="2" column="0"> 
       <widget class="QLabel" name="label_3"> 
       <property name="text"> 
       <string>Current Position</string> 
       </property> 
       </widget> 
      </item> 
      <item row="1" column="1"> 
       <widget class="QLineEdit" name="lineEdit_2"/> 
      </item> 
      <item row="3" column="0"> 
       <widget class="QLabel" name="label_4"> 
       <property name="text"> 
       <string>X=</string> 
       </property> 
       </widget> 
      </item> 
      <item row="0" column="1"> 
       <widget class="QLineEdit" name="lineEdit"/> 
      </item> 
      <item row="5" column="1"> 
       <spacer name="verticalSpacer"> 
       <property name="orientation"> 
       <enum>Qt::Vertical</enum> 
       </property> 
       <property name="sizeHint" stdset="0"> 
       <size> 
       <width>20</width> 
       <height>40</height> 
       </size> 
       </property> 
       </spacer> 
      </item> 
      </layout> 
      </widget> 
      </widget> 
     </item> 
     </layout> 
     </widget> 
     <widget class="QWidget" name="tab_2"> 
     <attribute name="title"> 
     <string>Tab 2</string> 
     </attribute> 
     </widget> 
     </widget> 
    </item> 
    </layout> 
    </widget> 
    </widget> 
</widget> 
<resources/> 
<connections/> 
</ui> 
+0

我改變了* .UI文件在scrollArea中使用網格佈局,但它不起作用滾動條仍然不顯示 – Whospal

+0

@Whospal:在另一個裏面的每個小部件應該在'否則他們不能相互溝通調整大小這就是'QLayout'及其派生類的全部內容,你仍然沒有這樣做,我添加了一個模擬你的設計的'.ui'文件,但是請仔細閱讀並檢查它以及我在答案中提供的文檔鏈接 – Avaris

+0

最初,我沒有看到您的用戶界面如何在沒有佈局小部件的情況下工作,這是我爲我的標籤和LineEdits所做的工作在tabWidget的scrollArea中。然後我查看了屬性並注意到一些小部件的佈局屬性設置爲Grid或Vert。我假設這是通過使用RightClick並選擇佈局選項完成的。 我修改了我的UI到你的示例,它的工作原理!非常感謝! 現在我明白QT4是如何工作的。 :) – Whospal

0

我已經修改了InfoPanel.ui(在scrollArea部件內的網格​​佈局,以取代幀)。

InfoPanel.ui:

<?xml version="1.0" encoding="UTF-8"?> 
<ui version="4.0"> 
<class>MainWindow_InfoPanel</class> 
<widget class="QMainWindow" name="MainWindow_InfoPanel"> 
    <property name="geometry"> 
    <rect> 
    <x>0</x> 
    <y>0</y> 
    <width>602</width> 
    <height>263</height> 
    </rect> 
    </property> 
    <property name="windowTitle"> 
    <string>MainWindow Info Panel</string> 
    </property> 
    <property name="documentMode"> 
    <bool>false</bool> 
    </property> 
    <widget class="QWidget" name="centralwidget"> 
    <widget class="QFrame" name="frame_Info_Panel"> 
    <property name="geometry"> 
    <rect> 
     <x>20</x> 
     <y>50</y> 
     <width>261</width> 
     <height>161</height> 
    </rect> 
    </property> 
    </widget> 
    </widget> 
    <widget class="QStatusBar" name="statusbar"/> 
    <widget class="QDockWidget" name="dockWidget_Info_Panel"> 
    <property name="minimumSize"> 
    <size> 
    <width>300</width> 
    <height>140</height> 
    </size> 
    </property> 
    <property name="font"> 
    <font> 
    <weight>75</weight> 
    <italic>true</italic> 
    <bold>true</bold> 
    </font> 
    </property> 
    <property name="layoutDirection"> 
    <enum>Qt::LeftToRight</enum> 
    </property> 
    <property name="allowedAreas"> 
    <set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set> 
    </property> 
    <property name="windowTitle"> 
    <string>Info Panel</string> 
    </property> 
    <attribute name="dockWidgetArea"> 
    <number>2</number> 
    </attribute> 
    <widget class="QWidget" name="dockWidgetContents_Info_Panel"> 
    <widget class="QTabWidget" name="tabWidget_Info_Panel"> 
    <property name="geometry"> 
     <rect> 
     <x>0</x> 
     <y>0</y> 
     <width>300</width> 
     <height>215</height> 
     </rect> 
    </property> 
    <property name="font"> 
     <font> 
     <weight>50</weight> 
     <italic>false</italic> 
     <bold>false</bold> 
     </font> 
    </property> 
    <property name="currentIndex"> 
     <number>0</number> 
    </property> 
    <widget class="QWidget" name="tab_1"> 
     <attribute name="title"> 
     <string>Info_Pg 1</string> 
     </attribute> 
     <widget class="QScrollArea" name="scrollArea_Info_Panel"> 
     <property name="geometry"> 
     <rect> 
     <x>9</x> 
     <y>9</y> 
     <width>271</width> 
     <height>171</height> 
     </rect> 
     </property> 
     <property name="verticalScrollBarPolicy"> 
     <enum>Qt::ScrollBarAsNeeded</enum> 
     </property> 
     <property name="widgetResizable"> 
     <bool>true</bool> 
     </property> 
     <widget class="QWidget" name="scrollAreaWidgetContents"> 
     <property name="geometry"> 
     <rect> 
      <x>0</x> 
      <y>0</y> 
      <width>269</width> 
      <height>169</height> 
     </rect> 
     </property> 
     <widget class="QWidget" name="gridLayoutWidget"> 
     <property name="geometry"> 
      <rect> 
      <x>0</x> 
      <y>0</y> 
      <width>261</width> 
      <height>161</height> 
      </rect> 
     </property> 
     <layout class="QGridLayout" name="gridLayout_Info_Panel"> 
      <item row="0" column="0"> 
      <widget class="QLabel" name="label_Eqpt_Model"> 
      <property name="text"> 
      <string>Eqpt Model:</string> 
      </property> 
      </widget> 
      </item> 
      <item row="1" column="1"> 
      <widget class="QLineEdit" name="lineEdit_State"> 
      <property name="enabled"> 
      <bool>false</bool> 
      </property> 
      <property name="palette"> 
      <palette> 
       <active> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </active> 
       <inactive> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </inactive> 
       <disabled> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </disabled> 
      </palette> 
      </property> 
      <property name="text"> 
      <string>Working</string> 
      </property> 
      </widget> 
      </item> 
      <item row="1" column="0"> 
      <widget class="QLabel" name="label_State"> 
      <property name="text"> 
      <string>State:</string> 
      </property> 
      </widget> 
      </item> 
      <item row="0" column="1"> 
      <widget class="QLineEdit" name="lineEdit_Eqpt_Model"> 
      <property name="enabled"> 
      <bool>false</bool> 
      </property> 
      <property name="palette"> 
      <palette> 
       <active> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </active> 
       <inactive> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </inactive> 
       <disabled> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </disabled> 
      </palette> 
      </property> 
      <property name="text"> 
      <string>ABC</string> 
      </property> 
      </widget> 
      </item> 
      <item row="2" column="0" colspan="2"> 
      <widget class="QGroupBox" name="groupBox_Current_Position"> 
      <property name="palette"> 
      <palette> 
       <active> 
       <colorrole role="WindowText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Button"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Light"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>170</red> 
        <green>255</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Midlight"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>127</red> 
        <green>255</green> 
        <blue>63</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Dark"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>42</red> 
        <green>127</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Mid"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>56</red> 
        <green>170</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="BrightText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>255</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ButtonText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Base"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>255</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Window"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Shadow"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="AlternateBase"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>170</red> 
        <green>255</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ToolTipBase"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>220</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ToolTipText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </active> 
       <inactive> 
       <colorrole role="WindowText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Button"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Light"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>170</red> 
        <green>255</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Midlight"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>127</red> 
        <green>255</green> 
        <blue>63</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Dark"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>42</red> 
        <green>127</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Mid"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>56</red> 
        <green>170</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="BrightText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>255</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ButtonText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Base"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>255</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Window"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Shadow"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="AlternateBase"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>170</red> 
        <green>255</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ToolTipBase"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>220</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ToolTipText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </inactive> 
       <disabled> 
       <colorrole role="WindowText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>42</red> 
        <green>127</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Button"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Light"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>170</red> 
        <green>255</green> 
        <blue>127</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Midlight"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>127</red> 
        <green>255</green> 
        <blue>63</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Dark"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>42</red> 
        <green>127</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Mid"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>56</red> 
        <green>170</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>42</red> 
        <green>127</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="BrightText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>255</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ButtonText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>42</red> 
        <green>127</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Base"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Window"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="Shadow"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="AlternateBase"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>85</red> 
        <green>255</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ToolTipBase"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>255</red> 
        <green>255</green> 
        <blue>220</blue> 
       </color> 
       </brush> 
       </colorrole> 
       <colorrole role="ToolTipText"> 
       <brush brushstyle="SolidPattern"> 
       <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>0</blue> 
       </color> 
       </brush> 
       </colorrole> 
       </disabled> 
      </palette> 
      </property> 
      <property name="title"> 
      <string>Current Position:</string> 
      </property> 
      <widget class="QLabel" name="label_Current_Position_X"> 
      <property name="geometry"> 
       <rect> 
       <x>20</x> 
       <y>20</y> 
       <width>41</width> 
       <height>27</height> 
       </rect> 
      </property> 
      <property name="text"> 
       <string>X =</string> 
      </property> 
      </widget> 
      <widget class="QLineEdit" name="lineEdit_Current_Position_X"> 
      <property name="enabled"> 
       <bool>false</bool> 
      </property> 
      <property name="geometry"> 
       <rect> 
       <x>60</x> 
       <y>20</y> 
       <width>161</width> 
       <height>27</height> 
       </rect> 
      </property> 
      <property name="palette"> 
       <palette> 
       <active> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
        <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
        </color> 
       </brush> 
       </colorrole> 
       </active> 
       <inactive> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
        <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
        </color> 
       </brush> 
       </colorrole> 
       </inactive> 
       <disabled> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
        <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>127</blue> 
        </color> 
       </brush> 
       </colorrole> 
       </disabled> 
       </palette> 
      </property> 
      <property name="text"> 
       <string>1000.00 m</string> 
      </property> 
      </widget> 
      <widget class="QLabel" name="label_Current_Position_Y"> 
      <property name="geometry"> 
       <rect> 
       <x>20</x> 
       <y>50</y> 
       <width>41</width> 
       <height>27</height> 
       </rect> 
      </property> 
      <property name="text"> 
       <string>Y =</string> 
      </property> 
      </widget> 
      <widget class="QLineEdit" name="lineEdit_Current_Position_Y"> 
      <property name="enabled"> 
       <bool>false</bool> 
      </property> 
      <property name="geometry"> 
       <rect> 
       <x>60</x> 
       <y>50</y> 
       <width>161</width> 
       <height>27</height> 
       </rect> 
      </property> 
      <property name="palette"> 
       <palette> 
       <active> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
        <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
        </color> 
       </brush> 
       </colorrole> 
       </active> 
       <inactive> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
        <color alpha="255"> 
        <red>60</red> 
        <green>60</green> 
        <blue>60</blue> 
        </color> 
       </brush> 
       </colorrole> 
       </inactive> 
       <disabled> 
       <colorrole role="Text"> 
       <brush brushstyle="SolidPattern"> 
        <color alpha="255"> 
        <red>0</red> 
        <green>0</green> 
        <blue>127</blue> 
        </color> 
       </brush> 
       </colorrole> 
       </disabled> 
       </palette> 
      </property> 
      <property name="text"> 
       <string>1000.00 m</string> 
      </property> 
      </widget> 
      </widget> 
      </item> 
     </layout> 
     </widget> 
     </widget> 
     </widget> 
    </widget> 
    <widget class="QWidget" name="tab_2"> 
     <attribute name="title"> 
     <string>Info_Pg 2</string> 
     </attribute> 
    </widget> 
    </widget> 
    </widget> 
    </widget> 
</widget> 
<resources/> 
<connections/> 
</ui> 

建立的* _UI.pt在命令提示符pyuic4 -o InfoPanel_UI.py InfoPanel.ui。

與Test_InfoPanel.py運行,仍然顯示其中垂直調整時滾動條沒有顯示同樣的結果。 :(

+0

你可以把它修改到你改變的代碼部分,並使用編輯而不是答案來向你的問題添加新的信息嗎? – BoltClock

+0

基於Avaris的示例,我曾嘗試使用dockWidget&scrollArea上的佈局。現在它可以工作。 – Whospal

+0

我收到你沒有注意到我的版主評論...? – BoltClock