qwidget

Pyqt5 addStretch in between widgets?

柔情痞子 提交于 2019-12-11 14:14:20
问题 I am using a QVBox layout and there are two widgets and a dynamic layout 'layout2' in the layout. Widget1 is fixed on top Widget3 is fixed at the bottom and widget2 is dynamic widget. layout2 is deleted and added each time. The problem here is I am not able to position the widget3 at the bottom as layout2 layout is deleted Widget3 moves to the top. Below is the sample code. class Screen(QWidget): def __init__(self): super(Screen, self).__init__() self.main_layout = QVBoxLayout() widget1 =

Custom Widget in QScrollArea Badly Redrawing Only on Scroll

我只是一个虾纸丫 提交于 2019-12-11 12:08:58
问题 I'm trying to get a custom scrolling widget in QT, and I'm getting redraw errors on scroll. Alt-tab or other redrawing events redraw correctly. I'm basing it on the example at http://doc.qt.io/qt-5/qtwidgets-widgets-charactermap-example.html repeatingwidget.cpp (excerpt): QSize RepeatingWidget::sizeHint() const { return QSize(500, itemHeight * displayItems.size() + 1); } void RepeatingWidget::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.fillRect(event->rect(), QBrush(Qt:

Python QtGui Calendar Widget Call button

一个人想着一个人 提交于 2019-12-11 11:39:09
问题 I am using a calendar widget for Python. And I need to call the widget when a button is clicked. The situation is that I cannot find what is the method in the calendar class that displays the widget itself. The calendar class was taken from here: http://www.eurion.net/python-snippets/snippet/Calendar_Date%20picker.html Here are my imports: from tkinter import * from tkinter import ttk import tkinter.messagebox import time import requests #needs to be installed import pymysql #needs to be

GUI freeze when using Windows::SetParent on QApplication

自古美人都是妖i 提交于 2019-12-11 09:07:42
问题 It is about the communication two Qt programs under Windows. One program, let's call him Client, The other program, called Server. The situation: I want to place the Client inside a QWidget of the server. Windows already supplies some nice methods for removing the decoration (border,title bar etc..) and change the parent of a window so repainting, resizing, window activation is all taken care by Windows. When I start my Client using a QProcess I wait for it to be launched, so that there is a

PyQT exit error in SPYDER

百般思念 提交于 2019-12-11 06:45:07
问题 This is PyQT code that I have to be executed in Spyder. The first time, I executed it, it works well. On the second time, it says: QWidget: Must construct a QApplication before a QPaintDevice " I searched for solution but nothing worked for me. from PyQt4 import QtGui, QtCore import sys class Window(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.button = QtGui.QPushButton('Test', self) self.button.clicked.connect(self.handleButton) layout = QtGui.QVBoxLayout(self)

How to set a custom widget's background color and border width?

老子叫甜甜 提交于 2019-12-11 06:37:16
问题 I have a custom widget whose parent is yet another custom widget. I am able to set the background color of the parent custom widget using QPalette and it works fine. But I am unable to set the child custom widget's border color using both QPalette and stylesheet . This is how I set my parent custom widget's background color: QPalette pal = parentCustomWidget->palette(); QColor color = {226, 208, 208}; pal.setColor (QPalette::Background, color); parentCustomWidget->setAutoFillBackground (true)

Borders and background of QWidget aren't set by stylesheet

泪湿孤枕 提交于 2019-12-11 04:54:24
问题 I've set the stylesheet of a QWidget to change the borders and the background, #gui { border: 4px inset #515c84; border-radius: 9px; background-image: url(./back.png) } Its name is gui but neither border nor background are shown. 回答1: Override paintEvent in your QWidget subclass like this: void MyWidget::paintEvent(QPaintEvent *e) { QStyleOption opt; opt.init(this); QStylePainter p(this); p.drawPrimitive(QStyle::PE_Widget, opt); } 回答2: For the Python-QT bindings (PyQt, PySide) just setting

Adding menus in main class derived from QWidget

*爱你&永不变心* 提交于 2019-12-11 04:43:12
问题 I'm trying to create a program in Qt that contains menus. The main class is derived from QWidget, and I know I could use QMainWindow to use the function menuBar(), but I can't use layouts in QMainWindow. I tried to add a QMenuBar at the window's layout using setMenuBar, but it does not display like using menuBar() and I don't know how to make it a drop-down menu. 回答1: QVBoxLayout *boxLayout = new QVBoxLayout(this); // Main layout of widget QMenuBar* menuBar = new QMenuBar(); QMenu *fileMenu =

Resizing Qt Widgets based on Window size

不问归期 提交于 2019-12-11 04:18:22
问题 I have certain Qt widgets inserted into QLayouts that are children of a Qt Window. I am trying to add a suggested size that the widgets need to be initialized with. I would also like Qt to resize the widgets proportional to what the Qt Window was resized. Additionally I would like to set an aspect ratio to the widgets that must be honored. However, the only way I can do so is using setFixedSize(). Though this widget cannot be rescaled with the window. Any suggestions?? EDIT: I tried

Learn about occurred events from other class

烈酒焚心 提交于 2019-12-11 04:13:10
问题 I have two classes: typedef std::shared_ptr<AdaptedWidget> window_ptr; class WindowManager { public: ... private: std::stack<window_ptr> m_windowsStack; } and class AdaptedWidget: public QWidget { Q_OBJECT public: AdaptedWidget(AdaptedWidget *parent = 0); bool event(QEvent *event); }; bool AdaptedWidget::event(QEvent *event) { if (event->type() == QEvent::NonClientAreaMouseButtonPress || event->type() == QEvent::MouseButtonPress) { qDebug() << "mainwindwo press"; } return QWidget::event(event