qmainwindow

PyQt: Accesing Main Window's Data from a dialog?

社会主义新天地 提交于 2020-01-02 06:54:05
问题 So, I'm using Python and PyQt. I have a Main Window that contains a QTableWidget, and a dialog that opens modally and has some QLineEdit widgets... All right so far, but I have 2 problems: When the dialog opens, my Main Window freezes, and I don't really like that... What I want, when I finish editing a QLineEdit, is that the program will search the QTableWidget, and if the text from the QLineEdit exists in the table, a dialog will come up and informe about that. That's the general idea. But,

Qt: Set size of QMainWindow

与世无争的帅哥 提交于 2020-01-01 07:47:29
问题 I'm new to Qt, so I wonder whether there is a way to set the size of a QMainWindow to (for example) 70% of the user's desktop. I tried the stretch factor but it didn't work. QWidget::setFixedSize worked but only with a pixel number, I think. 回答1: Thanks to Amir eas. The problem is solved. Here's the code for it: #include <QDesktopWidget> #include <QMainWindow> ... QDesktopWidget dw; MainWindow w; ... int x=dw.width()*0.7; int y=dw.height()*0.7; w.setFixedSize(x,y); 回答2: Somewhere in your

Qt: Set size of QMainWindow

痞子三分冷 提交于 2020-01-01 07:46:06
问题 I'm new to Qt, so I wonder whether there is a way to set the size of a QMainWindow to (for example) 70% of the user's desktop. I tried the stretch factor but it didn't work. QWidget::setFixedSize worked but only with a pixel number, I think. 回答1: Thanks to Amir eas. The problem is solved. Here's the code for it: #include <QDesktopWidget> #include <QMainWindow> ... QDesktopWidget dw; MainWindow w; ... int x=dw.width()*0.7; int y=dw.height()*0.7; w.setFixedSize(x,y); 回答2: Somewhere in your

Keep QMainWindow minimized when QDialogs show()

心不动则不痛 提交于 2019-12-25 05:22:43
问题 I have an application with QMainWindow as the UI which is in minimized state, after some time the application throws a message by calling messageDlg->show() ( messageDlg is a QDialog object). Something like this void MainWindow::WarningDialog() { m_messageDialog = new QDialog(this); m_messageDialog ->show(); } This results in my QMainWindow in normal mode which I don't want to happen i.e. am trying to keep the application in minimized window even if any QDialog.show() is called. I don't want

How to made a QDockWidget appears in taskbar?

谁都会走 提交于 2019-12-24 07:00:08
问题 I use a subclass of QDockWidget with a little trick. The "topLevelChanged" signal is connected to this member slot : void MyDockWidget::updateWindowFlags(bool topLevel) { if (topLevel == true) { setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowTitleHint|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint); // "setWindowFlags" hides the widget, show it again show(); } } This works well (at least on Windows, which is my target) and display a "maximize" button in the title bar. Now

change QMainWindow PyQt5 after pressed button

自闭症网瘾萝莉.ら 提交于 2019-12-24 04:47:08
问题 I have generated my UI with Qt Designer: like this I have used the .ui file with the following python code: Ui_MainWindow, QtBaseClass = uic.loadUiType("vault.ui") Ui_Credentials, QtBaseClass = uic.loadUiType("credentials.ui") class Credentials(QMainWindow): def __init__(self): super(Credentials, self).__init__() self.ui = Ui_Credentials() self.ui.setupUi(self) class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self)

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

落爺英雄遲暮 提交于 2019-12-24 03:53:31
问题 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 can I fix this? Compiler : Python 3.7.4 32 bit IDE : Visual Studio Code OS : Windows 10 my code: import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import * from PyQt5.QtGui import * class Interface(QMainWindow): def __init__(self): super

Resize QMainWindow to minimal size after content of layout changes

佐手、 提交于 2019-12-23 13:35:09
问题 I'm using a subclass of QMainWindow , in which I declared a central widget. This widget contains, among other things, a QGridLayout , which holds a set of buttons. The amount of buttons can grow or shrink, depending on the user's input. The spacing is set to zero, so that all buttons are clumped together. By default, it looks like this: If the amount of buttons is increased, the grid and window will grow too just fine; if, however, the amount of buttons is reduced, it will look like this: Now

How to set QMainWindow title

和自甴很熟 提交于 2019-12-21 03:09:07
问题 How do I set the title of a QMainWindow? I tried googling and found setCaption(), but it appears it no longer works in Qt 4. 回答1: The method is setWindowTitle() : setWindowTitle(const QString &) http://doc.qt.io/qt-4.8/qwidget.html#windowTitle-prop 来源: https://stackoverflow.com/questions/4549859/how-to-set-qmainwindow-title

MenuBar Not Showing for Simple QMainWindow Code, Qt Creator Mac OS

匆匆过客 提交于 2019-12-19 00:58:48
问题 I have been having problems adding a menu item to the built in menu bar in a Qt desktop application. I copied the code provided in the QMainWindow class reference documentation for creating a menu to a very simple application. Unfortunately, it did not show up when the code was run. I am simply trying to add a “File” menu to the menu bar. I am running Mac OSX 10.9.3 and Qt Creator 5.3.1. The screenshots of my code are below. I tried both the uncommented and commented code in the mainwindow