qmainwindow

Wrong layout in QMainWindow?

ⅰ亾dé卋堺 提交于 2019-12-17 20:44:10
问题 I am getting wrong layout in PyQT5. What am I doing wrong? Is there some predefined small field size or similar? I created main window as QMainWindow and inside it a widget as central widget. This is how it looks like: class Main(QWidget): """The main widget with label and LineEdit""" def __init__(self, parent=None): super().__init__(parent) self.initUi() def initUi(self): """Initialize the UI of the main widget""" self.mySourceLabel = QLabel("Select your file:") self.mySourceLine = QLineEdit

PyQt: How to hide QMainWindow

偶尔善良 提交于 2019-12-17 16:31:13
问题 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): def __init__(self): super(Dialog_02, self).__init__() myQWidget = QtGui.QWidget() myBoxLayout = QtGui.QVBoxLayout() Button_02 = QtGui.QPushButton("Close THIS and Unhide Dialog 01") Button_02.clicked.connect(self.closeAndReturn) myBoxLayout.addWidget

How to put an image in QGraphicsView's scrollbar area?

别来无恙 提交于 2019-12-14 03:59:23
问题 Due to some restrictions image has to be in the class QMainWindow and scrollbars have to be the QGraphicsView class. This means that I have to add image in QGraphicsView class through QMainWindow class. "exit.png" exists in the folder from where I run this code. What is the proper way to add this picture? import sys from PyQt4 import QtGui from PyQt4 import QtCore class Window(QtGui.QGraphicsView): def __init__(self, parent=None): QtGui.QGraphicsView.__init__(self, parent) self.scene = QtGui

How to change the opacity of Qt MainWindow?

流过昼夜 提交于 2019-12-13 19:50:47
问题 How to change the opacity of the Qt MainWindow by some values? My main window contains nothing but just somehow I need to change the opacity using keystrokes. It looks like this now. I tried to set using this->setWindowOpacity(0.5); didn't get anything opacity effect. 回答1: The below works for me most of times (as long as we can run in stylesheet override problem with other ways). Consider change the last component of rgba to less than 255 for making it semi-transparent. widget->setStyleSheet(

Floating sub QMainWindow (QMainWindow as child widget of main QMainWindow)

痞子三分冷 提交于 2019-12-13 16:25:59
问题 I use a QMainWindow as child of my main QMainWindow . By that I get an other area which I can use for dockable widgets ( QDockWidget ). According to the following posts this is OK, it also works perfectly for me. https://qt-project.org/forums/viewthread/17519 http://www.qtcentre.org/threads/12569-QMainWindow-as-a-child-of-QMainWindow To make the QMainWindow behaving as a normal widget, I unset the window flag, this trick is mentioned in one of the posts above. Now I also want to be able to

hide qdialog and show mainwindow

烂漫一生 提交于 2019-12-13 07:46:16
问题 I have a Qdialog in which i get some inputs to use on my mainwindow. so it must appear first than mainwindow. the problem is that my mainwindow does not show up. here's my main.cpp #include <QtGui/QApplication> #include "planevolume.h" #include "dialog.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Dialog *dialog= new Dialog; dialog->show(); planevolume mainwindow; bool dialogcheck = dialog->isHidden(); if (dialogcheck==1) { mainwindow.show(); } else { } return app.exec()

QMainWindow::showMaximized() Doesn't Update Size

て烟熏妆下的殇ゞ 提交于 2019-12-12 20:26:32
问题 I'm trying to create a QMainWindow to encapsulate a QGraphicsView that I'm putting in it. I want it to start out maximized, so I do this: QMainWindow *mainWindow = new QMainWindow(); mainWindow->setWindowState(Qt::WindowMaximized); mainWindow->show(); qDebug() << mainWindow->size(); Which says my maximized window is 200x100, which is obviously incorrect. Am I missing some sort of update function? I don't get why it wouldn't update the size. I've also tried using showMaximized() with the same

Why doesn't menu get added?

北战南征 提交于 2019-12-12 12:23:15
问题 I'm clearly missing something here; why doesn't the File menu get added in this little example app? import sys from PySide.QtGui import * class Window(QMainWindow): def __init__(self): super(Window, self).__init__() self.setWindowTitle('Test') layout = QHBoxLayout() self.widget = QWidget() self.widget.setLayout(layout) self.setCentralWidget(self.widget) self.exitAction = QAction('Exit', self, shortcut=QKeySequence.Quit, triggered=self.close) self.fileMenu = self.menuBar().addMenu('File') self

Qt Splash Screen not showing

时光总嘲笑我的痴心妄想 提交于 2019-12-12 12:12:46
问题 I have this code, I want it to show a splash screen since it will be bigger, having had made a kind of timer so it is possible to see the splash screen working. The problem is I don't see the splash screen, but the code will be running while the splash screen doesn't appear, sending me directly to the main window without showing the splas screen. Here's my code. main.cpp #include <iostream> #include <QApplication> #include <quazip/quazip.h> #include "splashwindow.h" #include "mainwindow.h"

How to set QMainWindow as the modal one?

我与影子孤独终老i 提交于 2019-12-12 09:49:40
问题 I am using QMainWindow for GUI development of my project..One problem I am Stuck with is blocking all other visible windows from getting input, while one is in operation. I can not use QDialog.Because rich features of QMainWindow is required. How can I declare a particular window as modal? I tried with QWidget::setWindowMOdality() . Here is a demo program, what I tried but it didnt work. #include <QApplication> #include <QMainWindow> #include <QPushButton> int main(int argc, char **argv){