qmainwindow

Widgets are not shown in basic Qt application (QMainWindow)

烈酒焚心 提交于 2019-12-04 12:48:19
I am new to Qt and I am doing some practice with simple examples. I just wanted to test my knowledge with a simple application, by coding, in which user types a text in QLineEdit widget and the text will be shown in QLabel. There is no need for it to be useful. I just want to try. While compiling the application, I get no errors. However, QLabel and QLineEdit widgets are not visible when the window is opened. My codes are here: Window.h #ifndef WINDOW_H #define WINDOW_H #include <QMainWindow> class QGridLayout; class QLabel; class QLineEdit; class Window : public QMainWindow { Q_OBJECT public:

QMainWindow - wait until 'show' function is done

主宰稳场 提交于 2019-12-03 21:27:47
问题 Is there a signal that tells when 'show' function finishes? I have a problem in my code: If I write: QMainWinObj.show(); QMainWinObj.someGuiFunc(); the code doesn't work. But, if I write: QMainWinObj.show(); sleep(3000); QMainWinObj.someGuiFunc(); It does. So I think the problem is that 'show' dosn't finish its jub before I call 'someGuiFunc'. That's why I want to have some kind of a sign that 'show' is finished.. 回答1: This may be a bit dated but since nobody else answered it except the one:

PyQt5 draggable frameless window

别说谁变了你拦得住时间么 提交于 2019-12-03 14:06:43
问题 I found an example to set borders on a frameless window, however it's not draggable. How can I make a frameless window draggable? Especially if I can see an example it'll be awesome. Here is my example code(normally the code is longer, that's why there are much libraries just don't mind them); from PyQt5.QtWidgets import (QMessageBox,QApplication, QWidget, QToolTip, QPushButton, QDesktopWidget, QMainWindow, QAction, qApp, QToolBar, QVBoxLayout, QComboBox,QLabel,QLineEdit,QGridLayout,QMenuBar

How to set QMainWindow title

Deadly 提交于 2019-12-03 10:24:25
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. Edward Strange 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

MainWindow from code from the main.cpp in Qt

ε祈祈猫儿з 提交于 2019-12-02 22:29:34
问题 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

PyQt5 - in a QMainMenu, how to make a QWidget the parent (temporarily)?

坚强是说给别人听的谎言 提交于 2019-12-02 20:17:46
问题 I have a QMainWindow that I initialize with a QWidget . I want that each Time I'll press the button New In my QMainWiindow , it will open the QWidget temporarily (in my case, until mouse button release). I'm having trouble interacting QMainWindow with the QWidget . I tried many options, but it seemed like everything I tried tied the QWidget to the QMainWindow screen, and I don't want that. It will be easier with an example: TempWidgetMenu.py is my QMainWindow class. When I press New , a

PyQt5 - in a QMainMenu, how to make a QWidget the parent (temporarily)?

只愿长相守 提交于 2019-12-02 09:57:17
I have a QMainWindow that I initialize with a QWidget . I want that each Time I'll press the button New In my QMainWiindow , it will open the QWidget temporarily (in my case, until mouse button release). I'm having trouble interacting QMainWindow with the QWidget . I tried many options, but it seemed like everything I tried tied the QWidget to the QMainWindow screen, and I don't want that. It will be easier with an example: TempWidgetMenu.py is my QMainWindow class. When I press New , a QWidget will appear, it Will color the screen gray-ish, and will color a rectangle from a button press, to

Qt4: Placing QMainWindow instance inside other QWidget/QMainWindow

扶醉桌前 提交于 2019-11-30 20:35:23
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 often place QMainWindow instances in QTabBar without any problems. ps You may ask why do I need to use QMainWindow ? I want to place 2 widgets inside 1 form using vertical layout. I want both widgets to have seperate Toolbars directly over them. Maybe there is some other way to place toolbars inside plain QWidgets using QtCreator ? Edit First example

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

谁说胖子不能爱 提交于 2019-11-30 20:07:32
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.cpp source. mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow

Qt4: Placing QMainWindow instance inside other QWidget/QMainWindow

半世苍凉 提交于 2019-11-30 17:00:26
问题 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 often place QMainWindow instances in QTabBar without any problems. ps You may ask why do I need to use QMainWindow ? I want to place 2 widgets inside 1 form using vertical layout. I want both widgets to have seperate Toolbars directly over them.