qt5

Apply different QSS stylesheet for custom QT class

旧时模样 提交于 2020-01-06 06:37:11
问题 I am using a qss stylesheet for my gui. It works well but I would like to define a different style sheet for my custom widget. By example, QPushbutton 's style works well but I would like to apply a different style for MyQPushButton (extends from QPushButton). I tried something like this : MyQPushButton { color: #dcdcdc; // some code here } QPushButton { color: #b1b1b1; // some code here } But QPushButton 's style has been applied on MyQPushButton . How to override this behavior ? 回答1: If you

Render QML without being visible, like a background task

拈花ヽ惹草 提交于 2020-01-06 05:26:06
问题 Suppose I have a map, and a few polygons. I want to render them and take a screenshot of each one of them. If the QQuickView is visible, thats easy. But, how could I achieve this, with the QQuickView not visible , like a background task ? Any ideas? I`m using Qt 5.12. 来源: https://stackoverflow.com/questions/59503641/render-qml-without-being-visible-like-a-background-task

QML: Dynamic view re-ordering in original model

霸气de小男生 提交于 2020-01-06 04:29:06
问题 Implemented QML Dynamic View Ordering by Dragging View Items using this Qt tutorial: QML Dynamic View Ordering Tutorial. Original underlying model is QAbstractListModel descendant in our case. Model stores data in a QList<QObject*> objectList; field type. Works fine, however item ordering changed in proxy DelegateModel only. How to change items order automatically in original underlying model as well for other C++ and QML consumers where order matters? Or I could we otherway access some

How to allow interactive resizing of floating Qt5 dock widget

杀马特。学长 韩版系。学妹 提交于 2020-01-06 04:23:07
问题 I have the following Qt5.11.0 code to create a qdockwidget. The nature of the widget is such that it makes sense to allow the user to interactively resize the widget, via mouse, as desired when the dockwidget is floating (the example below is contrived, but I believe illustrates the problem). When I run this and float the dockwidget into its own top-level window, it turns out to be either very hard (Linux) or impossible (OSX) to resize the dockwidget via user interaction. On RHEL Linux 7.6,

Hide future columns of QStandardItemModel in QTreeView

烈酒焚心 提交于 2020-01-06 01:29:06
问题 I have a QStandardItemModel . This model might get additional columns via an input widget. In addition, the QStandardItemModel is the model of a QTreeView . I would like to guarantee that just the first n columns of the QStandardItemModel are visualised in the QTreeView . How could I achieve this? But: The model is not aware of the view (expect Qt does something in the background) The view is not informed about the updated columns by my code. Nevertheless, the new columns are visualised. What

Draw content of QOpenGLFramebufferObject onto QOpenGLWidget

无人久伴 提交于 2020-01-06 00:53:10
问题 I am currently porting from Qt4 to Qt5. While Qt5 still provides the QGLWidget etc. classes, these are to be replaced by QOpenGLWidget etc. Currently I am drawing complicated stuff into a framebuffer object once. Then I draw it on the screen (into the GL widget) using drawTexture() method: target->drawTexture(rect, fb->texture()); Afterwards, I overdraw with other temporary things. So whenever I need to update the temporary stuff, I can just re-use the framebuffer object instead of redrawing

qt mouse event filter

天涯浪子 提交于 2020-01-05 16:48:33
问题 I have a QWidget with a QGraphicsView and a push button. The QGraphicsView has to take mouse press and release events to detect a swipe .At the same time push button should run a small function on clicked. I used an event filter in the QWidget to detect the mouse events. bool Widget::eventFilter(QObject * obj, QEvent * event) { // Capturing keyboard events for moving if( event->type() == QEvent::KeyPress ) { //Do something } //Capturing mouse events for swipe else if( event->type() == QEvent:

qt mouse event filter

杀马特。学长 韩版系。学妹 提交于 2020-01-05 16:48:08
问题 I have a QWidget with a QGraphicsView and a push button. The QGraphicsView has to take mouse press and release events to detect a swipe .At the same time push button should run a small function on clicked. I used an event filter in the QWidget to detect the mouse events. bool Widget::eventFilter(QObject * obj, QEvent * event) { // Capturing keyboard events for moving if( event->type() == QEvent::KeyPress ) { //Do something } //Capturing mouse events for swipe else if( event->type() == QEvent:

Finding the end of a Drag and Drop operation in QAbstractItemView

对着背影说爱祢 提交于 2020-01-05 10:33:42
问题 I created custom proxy model inherited by QSortFilterProxyModel. My source model for the above mentioned proxy model is also a custom model inherited by QAbstractTableModel. Then I set my custom proxy model to a QTableView. In this custom proxy model, I reimplemented the mimeData(..) function. It is as follows. QMimeData* CustomProxyModel::mimeData( const QModelIndexList & rListIndexes ) const { QMimeData *pMimeData = new QMimeData(); //some code here connect(pMimeData, SIGNAL( destroyed

Show, change data and keep QQmlListProperty in qml

最后都变了- 提交于 2020-01-05 08:49:08
问题 in the past i resolved a problem with QQmlListProperty for expose c++ qlist to qml, and the problem was resolved, now i try use their solution again, but i can't. the first time the list exposed to qml every time are different, this time no, i have a Qlist in a main class, and many data from her are loaded from db, and others changed in runtime. When the application start, the load of data and exposed to Qml is ok, i need change of page(gui) and keep the data stored in program and probably