qt5

Qt Forwarding signal/slot connections

蓝咒 提交于 2019-12-24 07:53:20
问题 Let's say SomeClass has members Object1 and Object2 and there is a connection between Object1 and Object2 like: connect(Object1, signal1, Object2, slot1) After some refactoring Object3 was added to SomeClass and Object2 was moved to be a member of Object3 , but still exist the need for the connection between Object1 and Object2 . The communication between Object1 and Object2 will have to go through Object3 now. This means Object3 needs to be modified, adding a pair of signal/slot just to

How to make a widget's height a fixed proportion to its width

爱⌒轻易说出口 提交于 2019-12-24 07:10:41
问题 I'm working on a PyQt5 application that needs to have a banner along the top. The banner is just a wide image, whose width should always be the width of the window, and whose height should be a fixed proportion. In other words, the banner image's height should depend on the width of the window. The widget beneath the banner (the main content) should stretch to fill all available vertical space. I've basically ported this SO answer to PyQt5: class Banner(QWidget): def __init__(self, parent):

How to auto change QPushButton width and QMenuBar corner widget width when change text of button?

天涯浪子 提交于 2019-12-24 07:09:57
问题 I set corner widget into QMenuBar that has two QPushButtons. But when I set long text by button's setText, button doesn't change it's weight, so, icon and part of text hiding. So, how to change button's width and width of corner widget when set text? 回答1: Call menuBar()->adjustSize(); after setting the text on the button. 回答2: I resolved it by setting the same corner widget into QMenuBar again after changing button text. 来源: https://stackoverflow.com/questions/15422439/how-to-auto-change

Qt (C++): dynamically style an individual tab in QTabWidget

孤者浪人 提交于 2019-12-24 06:43:33
问题 I know, that this question has been discussed here and on other sites, but there has not been a really solution yet, although I think, that I'm not the only one with this problem: How can I individually and dynamically access a single tab (not its content resp. the widget in the tab) for styling purposes, such as changing the background color or adding graphical effects to it? An application could be to notify the user, that a tab requires his attention, by letting it flash in another color

QCalendarWidget - How to Highlight Dates

泪湿孤枕 提交于 2019-12-24 06:24:49
问题 I have a QList<QDate> with dates to events, and I want to highlight those dates on a QCalendarWidget , hopefully, with an image, can be changing the cell color. I'm probably making a novice mistake in my code... This code that I modified from (Here) should make the QCalendarWidget paint the dates with a red border, but it doesn't... mainwindor.cpp MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_manager = new CalendarManager(ui-

Is it possible to modify QT qmake variable in the parent subdirs project?

情到浓时终转凉″ 提交于 2019-12-24 03:32:36
问题 I have the shared library project with structure like this: library.pro: TEMPLATE = subdirs CONFIG += ordered SUBDIRS += libs plugins test_programs ... QT += concurrent ... # Those files contains pure interfaces (C++ abstract classes) # with no implementation, and some helper classes with inline implementation. # So there is no reason to create yet another subproject for them HEADERS += iface/IInterface1.h \ iface/IInterface2.h \ # IInterface2 needs QtConcurrent ... IInterface2.h: ...

QSignalSpy::wait(…) fails, when QTest::qWait(…) succeeds

巧了我就是萌 提交于 2019-12-24 03:27:55
问题 It's a confusing situation i'm in. While testing state transitions for a QStateMachine, the following code fails to spy on the signal that causes the transition. // Test transition to SS_STARTING QSignalSpy spy(test_obj_, SIGNAL(StateChanged(int))); // emmit StateChanged signal test_obj_->SetState(SS_STARTING); // Current state property should be SS_STARTING QVERIFY(spy.wait()); //<--- fails test QVERIFY(test_obj_->GetCurrentState() == SS_STARTING); QCOMPARE(spy.count(), 1); The following

QDockWidget tabify/splitDockWidget weird behavior / bug?

江枫思渺然 提交于 2019-12-24 03:13:02
问题 I have an application with MdiChilds which should contain multiple QDockWidgets. I am however having troubles splitting/tabbing up the Widgets so that they produce the desired default layout. I basically want a layout like this: Widget 4 is created last and needs to go next to the tabified widgets 2 & 3. However, inserting it causes itself and another widget to go missing: Here's the code producing the second screenshot: In the constructor of the main window (or the mdi childs, doesn't really

TableView in QT5 doesn't show MYSQL Data, just empty rows are shown

三世轮回 提交于 2019-12-24 03:09:33
问题 I am showing you my problem by showing a screen shot. This seems easier to me. My Table is empty in my program, but it has the right amount of columns and if I add more columns in my sql workbench it will get more rows, but nothing is displayed in them. Here is my Source Code: void adminUserData::on_pushButton_Load_clicked() { // This Object is for connecting to my Database (it works). Datenbank db; db.connData(); QSqlQueryModel* model = new QSqlQueryModel(); QSqlQuery* qry = new QSqlQuery(db

How to return mouse coordinates in realtime?

不羁岁月 提交于 2019-12-24 02:58:10
问题 I'm new to PyQt and I'm trying to use it to create a widget that returns the position of the mouse in real time. Here's what I have: import sys from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication) from PyQt5.QtGui import QFont class MouseTracker(QWidget): def __init__(self): super().__init__() self.initUI() self.setMouseTracking(True) self.installEventFilter(self) def initUI(self): self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Mouse Tracker') self.show() def