Question

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_())
Was it helpful?

Solution

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) 

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top