1

I'm loading the QDockWidget and it does load fine and has the content but it seems that doesn't have a fixed size that avoids it's content to be hidden once loaded.

this is how it looks when is loaded:

enter image description here

and this is how it looks when manually drag it open (and how should look when loaded):

enter image description here

code:

    self.mdo = QMdiArea()
    self.buttons = QDockWidget('buttons', self.mdo)
    self.buttonsreen = QWidget()
    self.buttonsreen.resize(400,300)
    self.buttonsreen.setWindowTitle('direccion')

    self.btnfront = QPushButton('adelante', self.buttonsreen)
    self.btnfront.setToolTip('avanza una foto')
    self.btnfront.resize(self.btnfront.sizeHint())
    self.btnfront.move(200, 0)
    self.btnfront.clicked.connect(frontbutton)

    self.btnback = QPushButton('atras', self.buttonsreen)
    self.btnback.setToolTip('retrocede una foto')
    self.btnback.resize(self.btnback.sizeHint())
    self.btnback.move(0,0)
    self.btnback.clicked.connect(backbutton) 
    self.buttons.setWidget(self.buttonsreen)
    self.iface.addDockWidget(Qt.RightDockWidgetArea, self.buttons)

How is it forced to open with that specific size and how do I avoid other widgets to hide the buttons?

0

To solve the problem you just need to add this line to the code:

self.buttonsreen.setMinimumSize(QSize(400,30))

To set a size rule to the Widget going inside the QDockWidget, in this case self.buttonscreen meaning that this widget can't be resized to less than width=400 and height=30

So in the end it would look like:

self.mdo = QMdiArea()
self.buttons = QDockWidget('Direccion', self.mdo)
self.buttonsreen = QWidget()

self.btnfront = QPushButton('adelante', self.buttonsreen)
self.btnfront.setToolTip('avanza una foto')
self.btnfront.resize(self.btnfront.sizeHint())
self.btnfront.move(200, 0)
self.btnfront.clicked.connect(frontbutton)

self.btnback = QPushButton('atras', self.buttonsreen)
self.btnback.setToolTip('retrocede una foto')
self.btnback.resize(self.btnback.sizeHint())
self.btnback.move(0,0)
self.btnback.clicked.connect(backbutton) 

self.buttons.setWidget(self.buttonsreen)
self.buttonsreen.setMinimumSize(QSize(400,30))

self.iface.addDockWidget(Qt.RightDockWidgetArea, self.buttons)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.