简体   繁体   中英

python pyqt wider window than screen width

I tried to set window dimensions with self.resize(1450,250) more than is my screen resolution (1280, 800). But it limits window width to max 1280.

How can I set window width wider than my screen width?

my code:

from PyQt4 import QtCore, QtGui, QtNetwork, QtWebKit

class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.view = QtWebKit.QWebView(self)

        self.setGeometry(3,30,800,800) # Position window
        self.resize(1450,250)  # Resize window


if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    programwindow = MainWindow()
    programwindow.show()

    sys.exit(app.exec_())

first of all, in resize(), The size is adjusted if it lies outside the range defined by minimumSize() and maximumSize() .

It seems that you want a fixed size for your application. You can use (in the constructor):

self.setFixedSize(1450,250)

which basically "Sets both the minimum and maximum sizes of the widget"

I would suggest to set both geometry and size in main :

programwindow.setGeometry(3,30,800,800)
programwindow.setFixedSize(1450,250) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM