qwidget

Why isn't the “rectangle” that I want to draw on my Qt widget showing up?

瘦欲@ 提交于 2019-12-11 03:32:42
问题 I basically want to display a rectangle on a dialog window widget. Using another question as reference, I tried to adapt the framework of using a QLabel and painting to it (the process overall seems overly complicated). I started by making a member in the dialog box's class: QLabel* label; In the constructor of the dialog box: label = new QLabel(this); label->setGeometry(20, 50, 50, 100); Just to try and make it work, I gave the dialog box a button to make the "rectangle" created with the

QWidget transparent background (but not the children)

早过忘川 提交于 2019-12-11 02:56:14
问题 I have a QWidget that contains a QPixmap and a QComboxBox in its Layout. I would like to set the background of the widget transparent (but I want to show the QPixmap and the QComboBox normally). How do I do that? 回答1: It is all well-explained in QWidget documentation: http://doc.qt.io/qt-5/qwidget.html#transparency-and-double-buffering 回答2: You can use the attribute widget->setAttribute(Qt::WA_NoSystemBackground); Qt documentation : Indicates that the widget has no background, i.e. when the

Can QWidgets be added to QWindow?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 00:03:08
问题 It's now recommended to use QWindow for OpenGL drawing. Is it possible to add a widget to this window? If so, how? If not, how should I go about adding widgets to an OpenGL program using Qt5? 回答1: An application will typically use QWidget or QQuickView for its UI, and not QWindow directly. QWindow is more low level than QWidget . If you want to use QWindow directly, more work is needed to accomplish the job. You should manually do all drawing related things which is not easy. However, if you

Why does the border of QWidget cover the contents?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 23:31:18
问题 I have a custom widget derived from QWidget , which has a minimumSize of (30, 30) and a QLabel as a childWidget : MyWidget::MyWidget (QWidget *parent, QPoint p, QWidget *childWidget) : QWidget (parent) { childWidget = this->childWidget; setAttribute (Qt::WA_DeleteOnClose); this->move (p); verticalLayout = new QVBoxLayout (this); if (childWidget != NULL) { childWidget->setParent (this); childWidget->releaseMouse(); childWidget->setAttribute (Qt::WA_TransparentForMouseEvents, true);

event providing to QWidget(QWT) embedded into QML Qt4

£可爱£侵袭症+ 提交于 2019-12-10 22:25:41
问题 I've used QwtPlot (Qwt 6.0.1) in QML project (Qt 4.8) . i'm wrap it via QDeclarativeItem GraphWidgetQML::GraphWidgetQML(QDeclarativeItem *parent):QDeclarativeItem(parent) { _GraphArea = new GraphWidget; //child of QwtPlot without event handlers overrides QGraphicsProxyWidget *_wiget = new QGraphicsProxyWidget(this); _wiget->setWidget(_GraphArea); _wiget->setFlag(QGraphicsItem::ItemIsFocusable,true); this->setClip(true); } and insert into into QML via code qmlRegisterType<GraphWidgetQML> (

Qt/X11: How to make a QWidget override-redirect / calling XChangeWindowAttributes() with QWidget

非 Y 不嫁゛ 提交于 2019-12-10 20:45:49
问题 Does anybody has an example how to make a QWidget instance (as toplevel window) override-redirect with the X11 library? the following code doesn't work: QWidget* widget = new QWidget(); XSetWindowAttributes attr; attr.override_redirect = true; XChangeWindowAttributes(display, widget->winId(), CWOverrideRedirect, &attr); widget->show(); Does anybody has an idea? The bigger toplevel-problem i try to solve is the following: QWidget / X11: Prevent window from beeing activated/focussed by mouse

QWidget background-image fit

妖精的绣舞 提交于 2019-12-10 19:42:32
问题 I'm working with Qt 4.7 , I set a QWidget's background-image CSS an image from my qrc. The problem is the image is High res , and only the upper left part of it is showing , I can't get it to scale down to fit. In CSS3 I saw a "background-size : contain" property but I fear it doesn't work in Qt 4.7. Couldn't find a way to make the image fit the window. Any ideas ? I don't mind doing it programmatically . Thanks Solved: http://www.developer.nokia.com/Community/Wiki/Archived:Load,_Resize_image

QWidget reports wrong width value

南笙酒味 提交于 2019-12-10 18:49:11
问题 I want to query a widget's width to carry out some custom layout management. Unfortunately, the following code returns 640 no matter how big or small the widget actually is int myWidth = this->rect().size().width(); // "this" is my class derived from QWidget // myWidth is set to 640 EDIT: int myWidth = this->width() returns the same 640 回答1: Correct place to do special layout management is overridden resizeEvent. At that point size of widget is decided (usually by parent widget's layout,

Multiple widgets on a QDockWidget

故事扮演 提交于 2019-12-10 14:44:52
问题 I'm making a little app for applying various filters on an image using Qt and C++. My question is, is it possible to add multiple widgets on a QDockWidget ? As i want to add buttons for re-applying the last 5 filters on the dock. Here is an example of what i want to achieve. 回答1: It is possible add to multiple QWidget s into any QWidget . It looks like you probably want to do something like this: QDockWidget dock(QLatin1String("Last filters")); QWidget* multiWidget = new QWidget();

QWidget update events but no visual update

泪湿孤枕 提交于 2019-12-10 13:32:45
问题 Using Qt4.8 on a Mint Linux 12, I implemented a simple window containing a QTableView to show contents of a model. The model data is continually updated (log messages) and the dataChanged() signal is emitted on a regular basis (i.e. every 100ms). The problem I see is stuttering visual updates on the table. I installed an event filter on the window that counts updateRequest -type events, which should trigger a widget repaint (also on child widgets, i.e. the tableView ). These come in with an