qmainwindow

MainWindow from code from the main.cpp in Qt

a 夏天 提交于 2019-11-29 17:02:35
Want to understand the difference in code between the MainWindow and the main.cpp . Specifically, how a chunk of code written exclusively in the main.cpp needs to be modified to be part of the mainwindow.cpp and mainwindow.h . As an example, I am trying to modify the code from this fine answer to work in MainWindow . main.cpp #include <QtWidgets> #include <QtNetwork> int main(int argc, char *argv[]) { QApplication a(argc, argv); //setup GUI (you could be doing this in the designer) QWidget widget; QFormLayout layout(&widget); QLineEdit lineEditName; QLineEdit lineEditGender; QLineEdit

How to show clickable QFrame without loosing focus from main window?

穿精又带淫゛_ 提交于 2019-11-29 12:59:21
Finally I am able to create a chrome like tab in Qt/PyQt QMainWindow . After unsuccessfully trying to port this Qt C++ non client area painting code , I revise my thinking to be this way : trick visually by displaying a free floating QFrame that get resized and moved together with main window. Surely this is not a perfect solution (for example this code still don't solve when to disable topmost hint where the another application is on top of the main application window, but I think that's quite easy to solve) What I want to ask in this page, is how to keep the click action on this QFrame

PyQt: RuntimeError: wrapped C/C++ object has been deleted

放肆的年华 提交于 2019-11-29 09:28:51
If I run this code: #!/usr/local/bin/ python3 import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Window(QMainWindow): def __init__(self): super().__init__() self.button1 = QPushButton("1") self.button2 = QPushButton("2") self.setCentralWidget(self.button1) self.button1.clicked.connect(lambda: self.setCentralWidget(self.button2)) self.button2.clicked.connect(lambda: self.setCentralWidget(self.button1)) self.show() if __name__ == '__main__': import sys app = QApplication(sys.argv) window = Window() sys.exit(app.exec_()) ...I get this output: Traceback (most recent call last):

How to set a window icon with PyQt5?

送分小仙女□ 提交于 2019-11-29 03:45:33
问题 from PyQt5 import QtWidgets, QtGui from PyQt5.QtWidgets import * from PyQt5.QtCore import * class Application(QMainWindow): def __init__(self): super(Application, self).__init__() self.setWindowIcon(QtGui.QIcon('icon.png')) I am trying to set a window icon (top left of the window) but the normal icon disappeared instead. I tried with many icon resolutions (8x8, 16x16, 32x32, 64x64) and extensions (.png and .ico). What am I doing wrong? 回答1: The answer has been given by the asker (invisible

PyQt: Change GUI Layout after button is clicked

末鹿安然 提交于 2019-11-28 07:47:57
Okay, I am jumping from Tkinter to PyQt, because PyQt is just so much more advanced, and nicer to work with. BUT! I am having some troubles here. I am trying to change the GUI layout after I press one of my buttons on the main screen. I press the first button of the main GUI page, then I want it to go to another GUI page that I will create. I have been sitting here for hours trying to find some way to do this - no videos on YouTube, and I haven't found any stack-overflow pages that help. So I learnt that there is a Qt Designer program. I don't like programs like that, so please try to stay

How to show clickable QFrame without loosing focus from main window?

懵懂的女人 提交于 2019-11-28 06:52:50
问题 Finally I am able to create a chrome like tab in Qt/PyQt QMainWindow. After unsuccessfully trying to port this Qt C++ non client area painting code, I revise my thinking to be this way : trick visually by displaying a free floating QFrame that get resized and moved together with main window. Surely this is not a perfect solution (for example this code still don't solve when to disable topmost hint where the another application is on top of the main application window, but I think that's quite

PyQt: RuntimeError: wrapped C/C++ object has been deleted

独自空忆成欢 提交于 2019-11-28 02:44:25
问题 If I run this code: #!/usr/local/bin/ python3 import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Window(QMainWindow): def __init__(self): super().__init__() self.button1 = QPushButton("1") self.button2 = QPushButton("2") self.setCentralWidget(self.button1) self.button1.clicked.connect(lambda: self.setCentralWidget(self.button2)) self.button2.clicked.connect(lambda: self.setCentralWidget(self.button1)) self.show() if __name__ == '__main__': import sys app = QApplication(sys

Can you add a toolbar to QDialog?

亡梦爱人 提交于 2019-11-27 23:41:38
问题 I'm working on a project that needs to call a modal window with a toolbar to do some work on some data before it's loaded. The reason I need the toolbar is the user has a few different possible options that can be combined. The obvious choice here is a Modal dialog (which I have working right now). The issue is I want a toolbar. This is a two part question: Is it possible to add a toolbar to a QDialog ? (also is it possible to do this in Qt Designer?) If 1. is not possible, how can I make a

PyQt: How to hide QMainWindow

给你一囗甜甜゛ 提交于 2019-11-27 22:35:59
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(Button_02) myQWidget.setLayout(myBoxLayout) self.setCentralWidget(myQWidget) self.setWindowTitle('Dialog 02

PyQt: Change GUI Layout after button is clicked

放肆的年华 提交于 2019-11-27 01:45:54
问题 Okay, I am jumping from Tkinter to PyQt, because PyQt is just so much more advanced, and nicer to work with. BUT! I am having some troubles here. I am trying to change the GUI layout after I press one of my buttons on the main screen. I press the first button of the main GUI page, then I want it to go to another GUI page that I will create. I have been sitting here for hours trying to find some way to do this - no videos on YouTube, and I haven't found any stack-overflow pages that help. So I