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
5
votes
1 answer

PyQt5 - How to display image in QMainWindow class?

I'm trying to display a picture in a QMainWindow class: from PyQt5.QtWidgets import QLabel, QMainWindow, QApplication from PyQt5.QtGui import QPixmap import sys class Menu(QMainWindow): def __init__(self): super().__init__() …
TheCrystalShip
  • 249
  • 2
  • 4
  • 12
5
votes
1 answer

Promote QWidget to QMainWindow or add QMainWindow to QWidget from Qt Designer

My problem: I want to customize the way the title bar works and looks for my application. My idea: I created a new QWidget form in Qt Designer and added a QWidget to it. I added the following code in…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
5
votes
2 answers

I try to use QFileDialog for choose a file on PyQt but it don't run

I'm new on stackoverflow. I have a MainWindow on PyQt, I want click a button and open a QFileDialog for choose a file. The problem is: If I use a MainWindow, QFileDialog don't run. If I use a Dialog, QFileDialog run. This is my code for the…
Gianluca
  • 142
  • 1
  • 4
  • 13
5
votes
2 answers

How to change window title and central widget in Qt?

Hi, I have a problem with changing window title and central widget in Qt. There is MainWindow: class MainWindow : public QMainWindow { // (...) QStackedWidget* widgets; Quiz* widget1, *widget2; } and there is a class Quiz: class Quiz :…
trivelt
  • 1,913
  • 3
  • 22
  • 44
5
votes
1 answer

Switching between one QToolButton to another in QT

I want to switch from one QToolButton to another in QToolBar. I have used QStackedWidget, their it is too simple to move from one widget to other but here I am not able to get how to move via using keyReleaseEvent. mywindow::mywindow() :…
Suresh
  • 745
  • 4
  • 11
  • 25
5
votes
6 answers

Qt - Make QMainWindow to non resizible in Qt Designer

Is it there a way to set a QMainWindow to be non-resizible in Qt Designer? I am seeing lots of coding examples but I want to do as much UI customization in Qt Designer as I can. So far I can only get this by setting the minimum size and maximum size…
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
5
votes
1 answer

Tabify 3 QDockWidget

How can I create a tabified dock for 3 widgets in QMainWindow? I'm using the code bellow: widget1 = new QDockWidget(this); widget1 ->setObjectName("name1"); addDockWidget(Qt::LeftDockWidgetArea, widget1); widget2 = new QDockWidget(this); widget2…
Victor
  • 8,309
  • 14
  • 80
  • 129
5
votes
4 answers

QMainWindow - wait until 'show' function is done

Is there a signal that tells when 'show' function finishes? I have a problem in my code: If I write: QMainWinObj.show(); QMainWinObj.someGuiFunc(); the code doesn't work. But, if I…
kakush
  • 3,334
  • 14
  • 47
  • 68
5
votes
1 answer

QT 4.8 padding in QMainWindow

I'm started studying QT. When I create a MainWindow and placing some widgets on it in ane layout, there is a gap between edge of window and widgets, like that: How can I switch off this gaps? layout()->setContentsMargins(0,0,0,0); and editing…
Ivan
  • 609
  • 8
  • 21
4
votes
2 answers

Qt/win: showMaximized() overlapping taskbar on a frameless window

I'm building an Qt-Application without the default window border as a frameless window. The window functions are included by setting window flags in the QMainWindow like: MainDialog::MainDialog(QWidget *parent): QMainWindow(parent),…
Audrey Delany
  • 113
  • 4
  • 12
4
votes
2 answers

Get reference of dock-widget added to QMainWindow

I use a software written using Qt and it has a QMainWindow object. I need to get the reference of a widget when added to QMainWindow object already exists. I have looked at Qt documentation. I hoped there was an event childAdded or something, but I…
Kadir Şahbaz
  • 418
  • 7
  • 21
4
votes
1 answer

Why are my labels stacking on top of each other inside my QHBoxLayout?

Simply enough, I want to add two labels inside an horizontal box layout using Python's PYQT5. When I execute this code, the two labels appear on top of each other, even though adding them to a QHBoxLayout should position them from left to right. How…
4
votes
1 answer

How to change default position of toolbar?

I'm using PyQt5, QMainWindow and I want to change default position of toolbar to the right. How can I do it? User can carry toolbar to the edges of the window using mouse, but how can I do it using program? def initUI(self): self.toolbar =…
Gunter-R
  • 85
  • 1
  • 5
4
votes
1 answer

PYQT5 QMainWindow setCentralWidget consisting of multiple box layouts

For a project in programming class we need to develop an application and have to use PYQT5 for the GUI. I have a class based on QMainWindow. There are some lines of code I don't quite understand. Below is the initialization: # Snippet 1 class…
Pascal
  • 67
  • 1
  • 4
4
votes
1 answer

Attempting to add QLayout "" to QWidget "", which already has a layout

i got a error when i want to add QWidget to QGridLayout. i'm new with PyQt, previously i create a simple GUI without using Class, but now i want to try create a simple gui using class in python although it's make me confuse, but i got this error…
Nedy Suprianto
  • 201
  • 1
  • 6
  • 14
1 2
3
34 35