-1

It's a tiny simple code.

In this code, self.showMaximized() is not working.

And even it's so tiny, I don't know why.

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class Window(QWindow):
    def __init__(self):
        QWindow.__init__(self)
        self.setTitle("title")
        self.showMaximized()
        # self.resize(400,300)
        # self.showMaximized()
        # self.showFullScreen()


app = QApplication(sys.argv)

screen = Window()
screen.show()

sys.exit(app.exec_())

Delete 'screen.show()', and then showMaximized() worked.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
baejusik
  • 71
  • 1
  • 8

1 Answers1

1

Either you need to use .showMaximized() only on newly created Object i.e., screen, but not in your constructor or only at the end of your constructor, but not twice.

Code:

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class Window(QWindow):
    def __init__(self):
        QWindow.__init__(self)
        self.setTitle("title")


app = QApplication(sys.argv)

screen = Window()
screen.showMaximized()

sys.exit(app.exec_())
shaik moeed
  • 5,300
  • 1
  • 18
  • 54
  • Wow. Even delete this code 'screen.show()' , Window class is initiating. if then, what is the role of 'screen.show()'? – baejusik Feb 24 '20 at 05:23
  • 1
    @baejusik Role of `.show()` and `.showMaximized` is similar. What your previous code doing is, first maximized the window(in a constructor) and again set default parameters(i.e., `screen.show()`) – shaik moeed Feb 24 '20 at 05:26
  • Now I understand. I thought that 'showMaximized' is just change it's window size. And it wasn't. Thank you. ^^ – baejusik Feb 24 '20 at 05:34