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
16
votes
1 answer

Qt Designer how to change background

This is an repost. I am kind of new in QtDesigner and wanted to do something about the uglyness of just some buttons. All i have done yesterday was looking on the internet on how to change the background color of a screen in Qt Designer. How to…
That One
  • 581
  • 2
  • 6
  • 17
16
votes
1 answer

PyQt: when are widgets with parents deleted?

Let's assume I want to create a dialog box, a child of my main program: from PyQt4 import QtGui, QtCore class WizardJournal(QtGui.QDialog): def __init__(self, parent): super(WizardJournal, self).__init__(parent) self.parent =…
JPFrancoia
  • 4,866
  • 10
  • 43
  • 73
16
votes
1 answer

How to get widget background QColor

I am trying to find out the background color of a QWidget or QGLWidget so that I can use it with qglClearColor() to make the OpenGL part appear natively within the widget (without for example a black background). I figured I could fetch…
Nils Werner
  • 34,832
  • 7
  • 76
  • 98
15
votes
7 answers

Qt: Can child objects be composed in their parent object?

In Qt, can I embed child widgets in their parent via composition, or do I have to create them with new? class MyWindow : public QMainWindow { ... private: QPushButton myButton; } MyWindow::MyWindow () : mybutton("Do Something", this) { …
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
15
votes
2 answers

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

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…
Spirine
  • 1,837
  • 1
  • 16
  • 28
15
votes
5 answers

Resizing qt widgets when their children are hidden

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…
laura
  • 7,280
  • 4
  • 35
  • 43
15
votes
2 answers

How to create screenshot of QWidget?

I work at my homework in Qt Creator, where I paint to QWidget and I need to save some part of this QWdiget. I tried to solve this problem: QPixmap pixmap; pixmap.copy(rectangle); // rectangle is part of QWidget, which I need to save …
avalagne
  • 359
  • 3
  • 7
  • 15
14
votes
1 answer

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

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…
Dave Mateer
  • 17,608
  • 15
  • 96
  • 149
14
votes
2 answers

Draw Rectangular overlay on QWidget at click

in my project i use a EventFilter for widgets, that are in a QHBoxLayout. If i clicked on an a widget, i want to draw a transparent overlay with blue color over the clicked widget. Is there a way to implement this? greetings
501 - not implemented
  • 2,638
  • 4
  • 39
  • 74
13
votes
3 answers

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

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…
Adrien Rey-Jarthon
  • 1,015
  • 2
  • 9
  • 22
13
votes
5 answers

Qt - QWidget: Cannot create a QWidget when no GUI is being used

I'm trying to run a simple Qt program, and when doing so, I get a console window mentioning: QWidget: Cannot create a QWidget when no GUI is being used, and the second line This application has requested the Runtime to terminate....., and the .exe…
Simplicity
  • 47,404
  • 98
  • 256
  • 385
13
votes
2 answers

How keep a QWidget always on top?

I have two buttons on my QMainWindow. One to btnShowKb and another btnHideKb. When i press btnShowKb it shows an QWidget. I want this QWidget always to be on top of all windows till I press btnHideKb. When its on top, I want both QWidget and…
Surjya Narayana Padhi
  • 7,741
  • 25
  • 81
  • 130
12
votes
5 answers

Using any c++ function as a Qt slot

Is there a way to use any C++ function as a Qt slot, without having its class inheriting from QWidget?
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
12
votes
5 answers

Is it possible to set the opacity of qt widgets?

I know that there is a function QWidget::setWindowOpacity(qreal level) but as written in the documentation this does only work for windows. Is there a way to make widgets that are lying inside layouts opaque too? What I'm trying to do is an…
Exa
  • 4,020
  • 7
  • 43
  • 60
12
votes
2 answers

Qt: shadow around window

I can add shadow to widget: QGraphicsDropShadowEffect *bodyShadow = new QGraphicsDropShadowEffect; bodyShadow->setBlurRadius(9.0); bodyShadow->setColor(QColor(0, 0, 0,…
Robotex
  • 1,064
  • 6
  • 17
  • 41
1
2
3
97 98