Note that there are some explanatory texts on larger screens.

plurals
  1. POWrong size in Qt widget + widget updage issue
    primarykey
    data
    text
    <p>Here is a pruned version of a problem I have using QT/linux. The program runs, but the size of the displayed widget is wrong (the contents, frame + labels, does not fit).</p> <p>I understood that the size of a windows should be computed fron its contents (children). Why is that not happening properly here?</p> <p>So the first question is, of course why this is happening.</p> <p>The real program actually updates the contents of the widget at run-time. I have tried to simulate that behavior by the insertion of the <code>main_window-&gt;show()</code> (commented <code>//SHOW1</code>). If this first <code>show()</code> call is made, then the second <code>show()</code> does not show the new contents the widget. I have tried with update without success...</p> <pre><code> #include &lt;QApplication&gt; #include &lt;QtCore&gt; #include &lt;QMainWindow&gt; #include &lt;QTabWidget&gt; #include &lt;QWidget&gt; #include &lt;QGroupBox&gt; #include &lt;QVBoxLayout&gt; #include &lt;QLabel&gt; #include &lt;stdlib.h&gt; int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow* main_window = new(QMainWindow); main_window-&gt;setObjectName("main_window"); main_window-&gt;resize(800, 600); main_window-&gt;setWindowTitle("Hello"); QTabWidget* node_tab_widget = new QTabWidget(main_window); // node_tab_widget-&gt;setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // node_tab_widget-&gt;setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); node_tab_widget-&gt;setObjectName(QString::fromUtf8("tab_widget")); node_tab_widget-&gt;resize(500, 400); QWidget* w= new QWidget(node_tab_widget); node_tab_widget-&gt;addTab(w, "TAB"); //main_window-&gt;show(); //SHOW1 QGroupBox* group_widget = new QGroupBox("GROUPNAME", w); QVBoxLayout* group_layout = new QVBoxLayout; group_widget-&gt;setLayout(group_layout); group_layout-&gt;addWidget((QLabel*)new QLabel("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;here1")); group_layout-&gt;addWidget((QLabel*)new QLabel("here2")); // group_widget-&gt;setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); main_window-&gt;update(); main_window-&gt;show(); return app.exec(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload