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
9
votes
2 answers

QT - Main Widget - Stack or Heap?

I am a little confused on whether I should prefer to initialize my main widgets on the stack or on the heap. In "C++ GUI Programming with QT 4," main widgets are initialized on the stack. Before I say more, I will explain what I mean: int main(int…
Serodis
  • 2,092
  • 4
  • 25
  • 34
9
votes
3 answers

Qt4: Placing QMainWindow instance inside other QWidget/QMainWindow

I'd like to place QMainWindow instance inside another QWidget (for example centralWidget of another QMainWindow). I'm wondering why it doesn't work ? QMainWindow inherits directly from QWidget. Placeing QWidget inside another QWidget works fine. I…
user666491
9
votes
2 answers

How to force QWidget to be shown in a separate window?

I have class MyWidget : public QWidget { Q_OBJECT public: explicit MyWidget (QWidget *parent); // ... }; // here is ALL the code in MyWidget constructor MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { glWidget = new…
artyom.stv
  • 2,097
  • 1
  • 24
  • 42
9
votes
1 answer

How to get QTabWidget title text of QWidget in Qt?

I know I can use the widget function of QTabWidget in order to get the the QPlanTextEdit from the specified tab. But how can I get the tab title text of the current tab widget? QPlainTextEdit* pTextEdit = NULL; QWidget* pWidget=…
Engo
  • 899
  • 3
  • 19
  • 49
9
votes
1 answer

Multiple windows in a single project

I have a requirement for my project to display two QML Windows each on one of the screen (one sender, one receiver). Both of the .qml requires me to include some Cpp models inside hence, I'm using QQmlApplicationEngine to register the Cpp models. I…
angelhalo
  • 131
  • 1
  • 1
  • 8
9
votes
1 answer

QScrollArea not working as expected with QWidget and QVBoxLayout

So I have this QFrame which is the parent widget (represented by this in the code). In this widget, I want to place a QWidget at 10 px from top (and 10 px from bottom, as a result of which it will have a height of 140px, whereas parent is 160px).…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
9
votes
2 answers

Qt widget displayed over other widgets

I have some information/notification widget that should be displayed when some even occurs. My idea was to have a widget that is hidden in top left corner and would be shown when needed. Problem is that if I just put there simple widget and show it,…
Dainius
  • 1,765
  • 1
  • 17
  • 36
9
votes
1 answer

QWidget does not draw background color

I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing three other items and another label. For the widget containing the button,…
Robert
  • 227
  • 1
  • 3
  • 9
9
votes
4 answers

Qt - Clear all widgets from inside a QWidget's layout

I have a QWidget in a dialog. Over the course of the program running, several QCheckBox * objects are added to the layout like this: QCheckBox *c = new QCheckBox("Checkbox text"); ui->myWidget->layout()->addWidget(c); This works fine for all the…
thnkwthprtls
  • 3,287
  • 11
  • 42
  • 63
9
votes
3 answers

Resize QStackedWidget to the page which is opened

I want my QStackedWidget to resize to the page which is opened. I got a lot of widgets attached to the first page, but the rest pages have only one button. So they stay so big, and the first page is ok. How can I make my QStackedWidget to have the…
Darkgaze
  • 2,280
  • 6
  • 36
  • 59
8
votes
2 answers

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

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…
Alex
  • 599
  • 1
  • 4
  • 16
8
votes
3 answers

Why is there a 1 at the top of a QTreeWidget?

There is a 1 at the top of a QtreeWidget. How do i fix it?
Geore Shg
  • 1,299
  • 5
  • 23
  • 38
8
votes
2 answers

Replace a widget in Qt

I have a base class which has some gui items that i have set positions of using the designer in Qt creator. Those items are: QWidget* w1; QWidget* w2; QWidget* w3; Now in a class that inherits that base class, I would like to "transform" those…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
8
votes
1 answer

Change disabled QIcon tint color

I have an application with a custom theme and the disabled icons are to brightly grayed. I would like to change the disabled icon tint color. Now I know there is a possibility like this: QTableWidgetItem *name = new QTableWidgetItem("test"); QIcon…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
8
votes
1 answer

Qt - change QWidget layout

Let's consider we have a QWidget and a QLayout named general_layout that contains other widgets and layouts. general_layout is set as the QWidget layout like this: setLayout(general_layout) Now I should to change the content of QWidget. How can I…
Narek
  • 38,779
  • 79
  • 233
  • 389