qwidget

QWidget on Mac OS X not focusing in Qt 5.x

我怕爱的太早我们不能终老 提交于 2019-11-30 08:19:35
问题 I have QSystemTrayIcon with QAction that opens new window of type QWebView. When the window loses focus and I select the QAction again, the window should regain focus. It does on Linux, but doesn't on Mac OS X. The problem is, that when I have another window open and active, let's say Google Chrome, when I call show() on the window I'm trying to open, it always gets opened under the Google Chrome, so I don't see it. The same goes for focusing, when I have multiple windows open, and my

How does one fill a QGridLayout from top-left to right?

房东的猫 提交于 2019-11-30 04:48:18
问题 I would like to fill a QGridLayout with QWidgets . The QWidgets need to appear in a top-left to top-right fashion and proceed to fill the down downwards after each row is filled with QWidgets . An example of a similar and familiar GUI is how Apple sorts its apps on the iPhone or iPad's home screen. The apps go top-left to top-right and proceed to go downward after each row is filled. Right now, whenever I add elements, they take up the entirety of the screen and/or aren't added next to each

Render QWidget in paint() method of QWidgetDelegate for a QListView

好久不见. 提交于 2019-11-30 02:08:12
i'm having difficulties implementing custom widget rendering in a QListView . I currently have a QListView displaying my custom model called PlayQueue based on QAbstractListModel . This is working fine with simple text, but now I would like to display a custom widget for each element. So I subclassed a QStyledItemDelegate to implement the paint method like this: void QueueableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); QWidget

Resizing qt widgets when their children are hidden

旧时模样 提交于 2019-11-29 17:01:40
问题 How would I go about resizing the widget when the retry child is hidden so that it looks as in the first image? The main layout is a QVBoxLayout, the retry child is a widget with a QVBoxLayout as well. I've tried the following: update() updateGeometry() setGeometry(childrenRect()) layout()->activate() on the main widget as soon as I've set the retry widget to hidden. Do I need to intercept some event to do this? 回答1: The adjustSize function may do what you want. 回答2: Here is a basic example

Keeping the aspect ratio of a sub-classed QWidget during resize

核能气质少年 提交于 2019-11-29 13:22:06
I'm creating a new widget, by subclassing the QWidget class. I'd like to be able to set a ratio (for its height and its width) for this widget, which will always be maintained. For this, I've always searched, using the Qt5 documentation, Google, and Stackoverflow. Obviously, I've found answers: in particular, this one . But, unfortunately, not even one is fully effective: Setting the sizeIncrement does totally nothing, even if the widget is a window I tried to overload resizeEvent, but I really don't know how to do this... If I follow this answer , two things: If the widget is a top-level

What Qt widget(s) to use for read-only, scrollable, collapsible, icon list

一个人想着一个人 提交于 2019-11-29 11:58:05
问题 I'm relatively new to Qt, and am not entirely familiar with the out-of-the-box widgets. I have a somewhat (but not very) complex widget to create, and don't want to reinvent any wheels. What is the best QWidget to use as a starting point to subclass and/or QWidgets to use to compose my widget. Here is the end-result I am looking for (apologies for the crude drawing): Key points: All icons will take up the same size, say 128 x 128. Ignoring the category groupings, they should all align in a

QWidget on Mac OS X not focusing in Qt 5.x

与世无争的帅哥 提交于 2019-11-29 06:31:15
I have QSystemTrayIcon with QAction that opens new window of type QWebView. When the window loses focus and I select the QAction again, the window should regain focus. It does on Linux, but doesn't on Mac OS X. The problem is, that when I have another window open and active, let's say Google Chrome, when I call show() on the window I'm trying to open, it always gets opened under the Google Chrome, so I don't see it. The same goes for focusing, when I have multiple windows open, and my QWebView might be the last one in the order, when I click the QAction to focus the window, it will always be

How to Clear all the Widgets in Parent Widgets?

a 夏天 提交于 2019-11-29 05:36:11
I am using the constructor QWidget(QWidget *parent) . This parent widget contains a lot of child widgets. I need to clear all the child widgets from the parent at runtime. How can I do this? You can use the following in your parent widget class: QList<QWidget *> widgets = findChildren<QWidget *>(); foreach(QWidget * widget, widgets) { delete widget; } galinette Previous answer is wrong!! You cannot use findChildren to delete a widget's children, because Qt4's findChildren recursively lists children. Therefore, you will delete children of children, which then may be deleted twice, potentially

Render QWidget in paint() method of QWidgetDelegate for a QListView

戏子无情 提交于 2019-11-28 23:03:53
问题 i'm having difficulties implementing custom widget rendering in a QListView . I currently have a QListView displaying my custom model called PlayQueue based on QAbstractListModel . This is working fine with simple text, but now I would like to display a custom widget for each element. So I subclassed a QStyledItemDelegate to implement the paint method like this: void QueueableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if (option

QLayout: Attempting to add QLayout “” to QWidget “”, which already has a layout

余生颓废 提交于 2019-11-28 22:32:35
问题 I want to create some tabs, and I read this answer: How to add a tab in PySide I use the code in the answer and made some changes. Cause my code has to read some files and get the name of my tabs from those file, so that I add a for loop in my code. And here is my code. from PySide import QtCore, QtGui import sys import dflash_controller as con if __name__ == "__main__": list = [['a', 3], ['b', 4], ['c', 5], ['d', 6]] app = QtGui.QApplication(sys.argv) wid = QtGui.QWidget() grid = QtGui