Questions tagged [qwidget]

QWidget is key part of the Qt C++ classes. QWidget is the base class of all the user interface elements in the Qt framework.

The widget is the atom of the user interface: it receives mouse, keyboard and other events from the window system, and paints a representation of itself on the screen. Every widget is rectangular, and they are sorted in a Z-order. A widget is clipped by its parent and by the widgets in front of it.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

1466 questions
11
votes
3 answers

Is there a way to add a QWidget to a QMenu in QtCreator

I'm creating a text editor and I'd like to put the QComboBox in the QMenu. I didn't find any method inside the QMenu that handled such a thing. The closest is QMenu::addAction(). I was wondering of getting around this hurdle. Thanks!
W.K.S
  • 9,787
  • 15
  • 75
  • 122
11
votes
1 answer

Detect resizing in Widget-window resized signal

I create a simple UI with Qt Designer and convert it to Python codes. I searched for any method to detect changing window size. This is the generated code : from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def…
Mahmood Kohansal
  • 1,021
  • 2
  • 16
  • 42
11
votes
0 answers

How can I set Qt tab order for a form with a composite widget?

I have a form written with Qt Designer, which contains a QWidget promoted to a custom widget I have. The custom widget contains several combo boxes. I want the form to have a reasonable tab order, with focus moving from the widget immediately before…
Brian
  • 2,511
  • 20
  • 26
11
votes
3 answers

How to change a parent widget's background when a child widget has focus?

I would like to highlight a QFrame, if one of it's child widgets has focus (so the users know where to look for the cursor ;-) using something along ui->frame->setFocusPolicy(Qt::StrongFocus); ui->frame->setStyleSheet("QFrame:focus…
Elwood
  • 268
  • 4
  • 9
11
votes
2 answers

How to put QWindow into QWidget's layout (Qt5)

I want to insert QQuickView to my old qt4 application in some widget layout. How to mix QWidget and QWindow in a single application? Are there any examples?
DEgITx
  • 960
  • 1
  • 13
  • 24
10
votes
2 answers

pyqt4 window resize event

I'm using python3 and pyqt4 and I want some code to run every time my QMainWindow is resized.I would like something like this self.window.resized.connect(self.resize) but resized is not a builtin function or method. Can anyone help.
chicken-me
  • 131
  • 1
  • 1
  • 6
10
votes
4 answers

Extending a common base: Diamond inheritance vs. QObject

I think I've run into a kind of diamond inheritance problem here. Qt provides a couple of spin boxes, for integer values, for doubles and also for dates/times. They all derive from QAbstractSpinBox: #include class QSpinBox: …
Kamajii
  • 1,826
  • 9
  • 21
10
votes
4 answers

Qt QStackedWidget Resizing Issue

I have a simple QStackedWidget with 3 different QWidgets in it. The minimum sizes of the QWidgets are (350x200), (200x100), and (450x450). So the problem I'm having is when I resize the QStackedWidget, it has a minimum size of the largest QWidget…
David Ludwig
  • 967
  • 2
  • 12
  • 26
10
votes
1 answer

Get a list of all QObjects created in a Application

To get a list of all the QWidgets created in an application we can simply call QApplication::allWidgets(). I've read the documentation, and I haven't found anything like this to get a list of all QObjects. If an application creates stand-alone…
BetterWalk
  • 101
  • 1
  • 4
10
votes
3 answers

QLineEdit with custom button

I need to implement LineEdit widget with possibility to add tool buttons at the right end of text area. I know two ways of doing that but both solutions seems ugly. 1) add tool buttons as child widgets of QLineEdit and handle resizeEvent to position…
ArmanHunanyan
  • 905
  • 3
  • 11
  • 24
10
votes
2 answers

QT How to embed an application into QT widget

In our project we have three independent applications, and we have to develop a QT control application that controls these three applications. The main window will be seperated to three sub windows - each one display another one application. I…
RRR
  • 3,937
  • 13
  • 51
  • 75
10
votes
2 answers

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

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…
stepanbujnak
  • 651
  • 6
  • 16
10
votes
1 answer

How can I prevent a QWidget from painting, but still respond to events?

I have a QGLWidget that renders an OpenGL scene inside a Qt application. I would like to add some other translucent Qt widgets that are overlaid on top of the QGLWidget. This is more difficult than with standard widgets since the OpenGL drawing…
Jason R
  • 11,159
  • 6
  • 50
  • 81
10
votes
2 answers

QWidget doesn't close when main window is closed

I'm trying to make a main window (QWidget) which open a new QWidget when a button is clicked but when I close the main window, the QWidget recently opened doesn't close. main.cpp QApplication a(argc, argv); MainWindow w; w.show(); return…
Alex L.
  • 813
  • 2
  • 17
  • 34
10
votes
2 answers

How can I know if the mouse is over the widget?

I am fairly new to Qt (PyQt - PySide). I am trying to build a custom widget which is a menu. However I have hit a hard road and I can not seem to be able to sort myself out. I've read the documentation but I don't think there is a mouse state I can…
Phil
  • 13,875
  • 21
  • 81
  • 126
1 2
3
97 98