qt

Unable to fully remove border of PyQt QGraphicsView

喜你入骨 提交于 2021-02-07 19:11:43
问题 I have tried calling self.setStyleSheet("background: transparent; border: transparent;") on a QGraphicsView, but it still leaves a 1 pixel border on the top edge. I have also tried replacing border: transparent; with border-style: none; , but it didn't work either. Here is a screenshot of the problem: What command will fully remove the border from the QGraphicsView? 回答1: You can use one of the following css rule: graphicsView.setStyleSheet("border-width: 0px; border-style: solid") or

Using QFileSystemModel with ListView

本秂侑毒 提交于 2021-02-07 19:04:58
问题 I'm trying to create a simple ListView that I can use to browse the file system, using QFileSystem . First, I tried to use code I've found that worked for QDirModel: main.qml: ListView { id: list width: 300 height: 500 model: DelegateModel { model: myFileModel delegate: Text{ id: txt text: fileName MouseArea { anchors.fill: parent onClicked: { //Switch directory when clicked list.model.rootIndex = list.model.modelIndex(index); } } } } main.cpp: int main(int argc, char *argv[]) { QApplication

Does casting pointers to integers define a total order on pointers?

荒凉一梦 提交于 2021-02-07 18:42:46
问题 (related to my previous question) In QT, the QMap documentation says: The key type of a QMap must provide operator<() specifying a total order . However, in qmap.h , they seem to use something similar to std::less to compare pointers: /* QMap uses qMapLessThanKey() to compare keys. The default implementation uses operator<(). For pointer types, qMapLessThanKey() casts the pointers to integers before it compares them, because operator<() is undefined on pointers that come from different memory

Does casting pointers to integers define a total order on pointers?

旧时模样 提交于 2021-02-07 18:42:28
问题 (related to my previous question) In QT, the QMap documentation says: The key type of a QMap must provide operator<() specifying a total order . However, in qmap.h , they seem to use something similar to std::less to compare pointers: /* QMap uses qMapLessThanKey() to compare keys. The default implementation uses operator<(). For pointer types, qMapLessThanKey() casts the pointers to integers before it compares them, because operator<() is undefined on pointers that come from different memory

Why am I getting QWindowsWindow::setGeometry: Unable to set geometry warning with Qt 5.12.0

穿精又带淫゛_ 提交于 2021-02-07 14:23:51
问题 I migrated some code from Qt 5.6.0 to 5.12.0. Suprisingly, I'm getting lots of warnings related to QWindowsWindow::setGeometry . Whenever a dialog is shown on top of another, I get this warning. I could isolate the problem in a MCVE, it's very simple and minimal, all parenting look good, however, we get the warning when button is pressed: QWindowsWindow::setGeometry: Unable to set geometry 132x30+682+303 on QWidgetWindow/'QDialogClassWindow'. Resulting geometry: 132x42+682+303 (frame: 4, 28,

QT/QML Android App, open app when click notification bar

我怕爱的太早我们不能终老 提交于 2021-02-07 14:17:47
问题 I make an QT for Android apps. When I click button notify bar seen above in tablet. But if click notify, my apps open/focus(don' know) with black window. How to do it simply. My code is: package org.ays.operation; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.app.PendingIntent; import android.content.Intent; public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity { private static

QMetaMethod from member function pointer

◇◆丶佛笑我妖孽 提交于 2021-02-07 13:54:19
问题 Given a pointer to a method of a QObject derived class: Is there a way of getting the QMetaMethod of the method the pointer is pointing to? I am basically looking for a function like QMetaMethod::fromSignal , but for slots. Note: I tried getting the index through static_metacall with QMetaObject::IndexOfMethod and using that for QMetaObject::method : void(Class::*method)() = &Class::method; int methodIndex = -1; void *metaArgs[] = {&methodIndex, reinterpret_cast<void **>(&method)}; const

QMetaMethod from member function pointer

雨燕双飞 提交于 2021-02-07 13:54:14
问题 Given a pointer to a method of a QObject derived class: Is there a way of getting the QMetaMethod of the method the pointer is pointing to? I am basically looking for a function like QMetaMethod::fromSignal , but for slots. Note: I tried getting the index through static_metacall with QMetaObject::IndexOfMethod and using that for QMetaObject::method : void(Class::*method)() = &Class::method; int methodIndex = -1; void *metaArgs[] = {&methodIndex, reinterpret_cast<void **>(&method)}; const

highlighting custom QWidgetAction on hover

喜欢而已 提交于 2021-02-07 13:34:44
问题 My application has a QMenuBar with a number of QMenu s, each of which having a number of QAction s and sub- QMenu s. Most of the QAction -items are derivatives of QWidgetAction with re-implemented QWidgetAction::createWidget methods. Usually, both QAction s and QMenu become highlighted on mouse hover. Even a QWidgetAction doesn't make trouble until here: But as soon as I override QWidgetAction::createWidget to return a custom QWidget QWidget* MyWidgetAction::createWidget(QWidget* parent) {

highlighting custom QWidgetAction on hover

旧街凉风 提交于 2021-02-07 13:34:14
问题 My application has a QMenuBar with a number of QMenu s, each of which having a number of QAction s and sub- QMenu s. Most of the QAction -items are derivatives of QWidgetAction with re-implemented QWidgetAction::createWidget methods. Usually, both QAction s and QMenu become highlighted on mouse hover. Even a QWidgetAction doesn't make trouble until here: But as soon as I override QWidgetAction::createWidget to return a custom QWidget QWidget* MyWidgetAction::createWidget(QWidget* parent) {