Questions tagged [qmainwindow]

QMainWindow is a class in Qt library that implements the main window of an application.

As a main window for the application, QMainWindow is different from an ordinary widget. It has a menu bar on the top, a status bar, it can also have toolbars and dock widgets.

It also have a so-called Central Widget, which can be occupied by any other widgets.

Qt also allows one to easily implement single- and multiply-document-interfaces with this class.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

516 questions
2
votes
1 answer

react on the resizing of a QMainWindow for adjust widget's size

How do I react on the resize of a QMainWindow? I have QTextBrowsers in a QScrollArea and I adjust them to the size of the content on creating them (the only thing that should scroll is the QScrollArea). Everything works for now, but if I resize the…
Florian
  • 3,145
  • 1
  • 27
  • 38
2
votes
0 answers

Why does my QDialogButtonBox not work in QMainWindow?

I create the UI in Qt Designer. If I use the "Dialog with Bottom Buttons" template, this works perfectly (with all the right modifications). If i use "Main Window" template, it opens and all looks good, it creates the window and buttons, but…
2
votes
1 answer

Adding QWidget in QMainWindow which already has a central widget in PyQt

I am developing a GUI app in PyQt. For the buttons, I have used QWidget and for a QSqlTable I have used a QMainWindow. I know I can add QWidget by adding setCentralwidget in QMainWindow. But in order to show the Table, I need the table to be central…
Sudipto21
  • 37
  • 1
  • 6
2
votes
1 answer

Catch the mouse event

Don't know exactly how to give the parameters of QMouseEvent class. Should I create new class to implement a QMouseEvent into my QTextEdit? class Test(QMainWindow): def __init__(self): super().__init__() self.txt =…
2
votes
2 answers

Is it possible to create QMainWindow with only outer border?

I am trying to rebuild a screen record PyQt App, and the ScreenToGIF is a very good demo for me, it creates an interface which only has the border and record contents in the "Central Widgets", like this: with key functions of: The border exists…
Howcanoe Wang
  • 133
  • 1
  • 8
2
votes
1 answer

menubar not working/disappearing when centralwidget is added to qmainwindow

I'm using PyQt5. My problem is that the menubar cannot be clicked after the centralwidget has been added to the QMainWindow. I'm using python 3.7 on Linux server. Here's a MWE for the problem I'm having: import sys from PyQt5.QtWidgets import…
Sam Kim
  • 23
  • 3
2
votes
1 answer

How to position multiple QDockWidget on QMainWindow in a specific way

I am trying to position N.5 QDockWidget according to the following lay-out in Figure 1 below: For some reasons when I add the second and the third QDockwidget on the QMainWindow they are positioned in a very different way and I don't understand if…
Emanuele
  • 2,194
  • 6
  • 32
  • 71
2
votes
1 answer

PyQt5: how do I launch a window from a system tray icon context menu?

I have two separate files, one that creates a system tray icon and context menu, and another a window to take user input. traywindow.py contains this: import sys import os from PyQt5 import QtCore, QtWidgets from PyQt5.QtWidgets import QMainWindow,…
Sidewinder
  • 369
  • 3
  • 13
2
votes
1 answer

Python PytQT5 - Windows Buttons move to other area

I am looking for help, I am developing a web browser using PyQT5 and its included web engine, however, I got one problem which I do not seem to find a way to solve. Basically, I am trying to move windows buttons - Minimize, Change windows Size and…
Gromis
  • 127
  • 1
  • 20
2
votes
1 answer

QGridLayout Widgets Overlapping

I am trying to create a program where the user has three options to answer a question. I used QGridLayout for this but only the last widget added to the QGridLayout is shown. Expected: ################################ # Text …
Penguin
  • 93
  • 2
  • 10
2
votes
1 answer

Open and save image file using menubar in PyQt5

I've written the following code to open image file using a menubar in PyQt5. It is able to select the file but not able to display it in the window. I've successfully opened text file but not able to do the same for images. Can you please rectify my…
2
votes
1 answer

QMainWindow vs QWidget

I can't find good explanations about the different usage of QMainWindow vs. QWidget in PyQt5 (and Qt in general, I guess). From what I've read, QMainWindow inherits from QWidget, so should be able to do everything QWidget can and more. But when I…
CodingCat
  • 4,999
  • 10
  • 37
  • 59
2
votes
1 answer

Minimize all application windows when a modal window gets minimized (on Linux)

I have an application with some windows, and one of them is modal. On Windows OS, when I minimize the modal window all other windows minimize as well. On Linux (I'm using Astra Linux) only the modal window minimizes and all other windows state…
2
votes
1 answer

How to access QMainWindow from a QWidget which parent is not QMainWindow

I am programming a GUI with Qt Creator (Qt5.10) under OSX. I have a QMainWindow for the main app's window. Inside this I have a QTab widget, in which I have entire widget (let's call it CaptureTabWidget which contains some additional widgets AND a…
2
votes
1 answer

QDockWidget splitter jumps when QMainWindow Resized

In an old program of mine, I have 2-column QTableWidget inside of a QDockWidget. Building it in modern times (Qt 5.10) I seem to have to override the table's sizeHint() to get it to be a width besides 100px or something. Which was a bit annoying…