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
9
votes
3 answers

Qt4: Placing QMainWindow instance inside other QWidget/QMainWindow

I'd like to place QMainWindow instance inside another QWidget (for example centralWidget of another QMainWindow). I'm wondering why it doesn't work ? QMainWindow inherits directly from QWidget. Placeing QWidget inside another QWidget works fine. I…
user666491
8
votes
2 answers

What is the rule for choosing "central widget" in QMainWindow? and why is it important?

I understand setCentralWidget is required in QMainWindow implementation, and at first sight, it seemed extremely self-explaining what central widget means. But is there a more strict definition of "central"? Say, I have several equally important…
JackOuttaBox
  • 345
  • 5
  • 12
8
votes
3 answers

Problem with hidden QMainWindow: application crashes after QMessageBox is displayed

// main.cpp #include #include "mainwindow.h" int main(int argc, char* argv[]) { QApplication app(argc, argv); MainWindow* window = new MainWindow(); window->show(); return app.exec(); } // mainwindow.cpp #include…
Andrey Moiseev
  • 3,914
  • 7
  • 48
  • 64
7
votes
3 answers

adding child in QMainWindow

How can i add two child Widget objects in equal portion of QMainWindow. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { TreeArea *ta= new TreeArea(this); TreeArea *ta1= new TreeArea(this); . . . …
anj
  • 355
  • 2
  • 5
  • 20
7
votes
1 answer

How to properly save window state in QML

I read the Qt Documentations, I checked out a couple examples provided with the SDK, I build Qt Creator from source to see how the Qt devs do it...still no luck. I am developing a cross platform application for Windows and Mac. On the Mac side I can…
Silex
  • 2,583
  • 3
  • 35
  • 59
7
votes
1 answer

Padding between QMainWindow and contained widgets

I'm trying to increase padding between widgets contained within a QMainWidget and the edges of the QMainWidget. You can see the problem in the image below: There is no padding between QTabWidget (which is central widget of the QMainWidget) and the…
ezpresso
  • 7,896
  • 13
  • 62
  • 94
7
votes
3 answers

Pyside Remove window flags

Im designing a Pyside Qt application and I want to toggle the QtCore.Qt.WindowStaysOnTopHint window flag in my main window. Setting this hint using this code works fine: self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.show() but I can't…
jonathan topf
  • 7,897
  • 17
  • 55
  • 85
7
votes
2 answers

Qt Designer can't promote QMainWindow

There is something I do not understand about Qt Designer. I have been working with it for a while now, and still I always end up editing the .ui files manually. As it can be seen in every single tutorial on Qt, one of the very first thing you do…
maxime-esa
  • 215
  • 1
  • 9
6
votes
2 answers

How to resize QMainWindow after removing all DockWidgets?

I’m trying to make an application consisting of a QMainWindow, the central widget of which is a QToolBar (it may not be usual, but for my purpose the toolbar’s well suited). Docks are allowed below only. I added a QDockWidget to it, and a QAction on…
neydroydrec
  • 6,973
  • 9
  • 57
  • 89
6
votes
3 answers

How to get the screen position of `QMainWindow` and print it?

I'm trying to get the screen position of QMainWindow and print the position (x,y) values. I have tried both self.pos() and self.mapToGlobal(self.pos()) and both of these return 0. import sys from PyQt5.QtWidgets import QApplication,…
artomason
  • 3,625
  • 5
  • 20
  • 43
6
votes
1 answer

PyQt5 QMainWindow, QDockWidget, fitting autosize with screensize

I've created aQMainWindow with menubar and 4 dockable widgets. First dockwidget contents multipletabs, second is Qpainter widget, third is Matlabplot and fourth is pdf report. When I run the code shows up like this below. I want to be like…
Pavel.D
  • 561
  • 1
  • 15
  • 41
6
votes
1 answer

PyQt: How to hide QMainWindow

Clicking Dialog_01's button hides its window and opens Dialog_02. Clicking Dialog_02's button should close its windows and unhide Dialog_01. How to achieve it? import sys, os from PyQt4 import QtCore, QtGui class Dialog_02(QtGui.QMainWindow): …
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
5
votes
1 answer

active resizing of widgets inside mainwindow

I have a few widgets in a main window. i want the user to be able to resize the widgets inside the window as they please, just like how one would resize the main window. Do I have to make a layout container to enable this? or ....layout? Buh the…
PeterG
  • 519
  • 2
  • 7
  • 15
5
votes
3 answers

Make a QMainWindow only horizontally-resizable - that is, width is resizable, but height is fixed

Can I make a QMainWindow with a grid layout resize only horizontally but not vertically? I want its vertical size to be the minimum needed to hold all the buttons/line edits.
sashoalm
  • 75,001
  • 122
  • 434
  • 781
5
votes
3 answers

How to update QMainWindow step by step?

I want to update my QMainWindow step by step. I use sleep method but I cannot see changes. I want to see changes every 3 seconds. void MainWindow::updateScreen() { ui->pushButton1->show(); QThread::sleep(3); ui->pushButton2->show(); …
sepfar
  • 53
  • 2
1
2
3
34 35