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
0
votes
0 answers

How to prevent a QMainWindow from being moved with moveEvent?

I would just like to be able to prevent my QMainWindow from being moved. I saw that it was possible to reimplement the moveEvent function. Here is what I tried: mainwindow.cpp void MainWindow::moveEvent(QMoveEvent *event) { qDebug() << "move"; …
Martin Denion
  • 352
  • 1
  • 3
  • 22
0
votes
0 answers

Display foreign window inside PyQt5 QMainWindow

I am using Windows 10 I am trying to display cmd to my PyQt5 Application I tried Running a Windows executable (calc.exe, etc) inside a PyQt Application But It just opens the application outside the PyQt5 application Can anyone help me? Thank you
0
votes
1 answer

How to have a Vispy.app.Canvas running directly in Vispy.app AND as a QWidget inside a QMainWindow

I would like to know how I can make the self.show() instruction at the end of my Vispy.app.Canvas init() dependant on the fact the canvas is basically run in a Vispy app or as a QWidget in a QMainWindow. So I have a Python3 Vispy app that run and…
GregVDS
  • 13
  • 4
0
votes
0 answers

PyQt5- Trying to change colour of lines under menubar in QMainWindow

I'm trying to change the colour of a couple of horizontal lines (the ones just above and below the horizontal toolbar) in a QMainWindow. I'm using QPalette to change the colours of the main window, and am able to set most things I want. However,…
0
votes
1 answer

toolbarBreak disappears when deleting QToolBar

When I execute the following example code, I first create two toolbars with a break between it and then I delete the second toolbar after that. The problem is that the toolbarBreak also disappears when I do that. When I reinitialize t2, there is no…
easysaesch
  • 159
  • 1
  • 14
0
votes
0 answers

PyQt5 Problem involving QMainWindow class, QAction and probably the setCentralWidget() function, what to do?

Good afternoon. This is an MRE of the problem that you can easily run in your machine import sys from PyQt5.QtWidgets import ( QWidget, QMenuBar, QMenu, QApplication, QAction, QMainWindow, QVBoxLayout, QLabel ) class…
zeca_abc
  • 41
  • 5
0
votes
0 answers

QMainWindow - No such file or directory using CMake

I have a problem using CMake and Qt5. So my project looks like this: ├── CMakeLists.txt ├── inc │   └── qtbasicapp │       ├── app │       │   ├── Application.hpp │       │   ├── fwd.hpp │       │   └── IApplication.hpp │       └──…
Kabuuz
  • 1
  • 1
0
votes
1 answer

Why while i want to open a second window on my Qt app, my header file does not recognize the second window?

i'm stuck with this for 2 days.. My code was building without any problems but since i made some changes that are not related with this (i think) it's not building anymore. So i want to open a new window from a button clicked on a first window to…
0
votes
1 answer

qt c++ QChart->setGeometry does not work in MainWindow

I created an object with a QChart inside and a MainWindow with 2 QPushButton, when I try to display my QChart, it takes all window. If I want to resize QChart everything works but if I try to move it nothing work (with setGeometry or with…
q7frkz
  • 13
  • 7
0
votes
0 answers

How to go to other forms by clicking a pushButton in Qt Widget Application

We have 2 ui forms. let's say form1.ui and form2.ui with their Header and Source files. In each form, there are a pushButton, a label and a variable QString. I want to show form2.ui by clicking the pushButton in form1.ui and show the form1.ui by…
0
votes
3 answers

Call a Python function with a variable name from a QMainWindow

I am trying to find an efficient and secure way to call different functions based on the transaction name the user enters. There are a 100+ different transactions. A 100 "IF" would do the job, however, I want to find a more efficent way to call the…
Andy
  • 5
  • 1
0
votes
1 answer

Central widget position of layout

Is there a way to postion or resize layout in central widget of qmain window. I am trying to write an app with QMainWindow. I am setting different Layout in central widget but the spacing of those widgets are completely different class…
T2Square
  • 5
  • 4
0
votes
0 answers

How to get closeEvent or similar on docked QMainWindow?

The behaviour I am wanting is to have multiple QMainWindows, docked within a top-level window. The docked windows will present some aspect of the application and I need to know when they close, but Qt only issues the closeEvent when a top-level…
Mark
  • 672
  • 1
  • 6
  • 19
0
votes
1 answer

Qt: Why does adding a status bar to QMainWindow messes up size adjustment?

In a sample Qt application, I create a QMainWindow with a QTableView as its central widget (see code at the end of question). Importantly, the size of the main window is computed to fit the table: However, if I add a status bar, the size is not…
user118967
  • 4,895
  • 5
  • 33
  • 54
0
votes
0 answers

I am switching in between a QMainwindow and Qdialog window but when I exit my QDIALOG It causes the whole program to crash

from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QDialog from PyQt5 import uic from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QPushButton from PyQt5.QtWidgets import QLineEdit from PyQt5.QtWidgets import…
Gabriel
  • 53
  • 5