Note that there are some explanatory texts on larger screens.

plurals
  1. POQt: view added to layout not updating, but will update when not in layout
    primarykey
    data
    text
    <p>A widget called Tachometer will update accordingly when a signal is sent from its corresponding model, but it will not respond at all when I add the widget to a layout. What might account for this? Without showing the internals of the model or the view (which would be exhaustive), I will attempt to point out where it is not working:</p> <pre><code>void MainWindow::setupWidgets() { QHBoxLayout *horiz1 = new QHBoxLayout(); QHBoxLayout *horiz2 = new QHBoxLayout(); odometer = new Odometer(ui-&gt;dashFrame); fuelGauge = new FuelGauge(ui-&gt;dashFrame); tripometer = new Tripometer(ui-&gt;dashFrame); tachometer = new Tachometer(ui-&gt;dashFrame); temperatureGauge = new TemperatureGauge(ui-&gt;dashFrame); oilPressureGauge = new OilPressureGauge(); QVBoxLayout *vertOPG = new QVBoxLayout(); if ( oilPressureGauge-&gt;getTitle() != "" ) { QLabel *OPGLabel = new QLabel(oilPressureGauge-&gt;getTitle()); vertOPG-&gt;addWidget(OPGLabel); } vertOPG-&gt;addWidget(oilPressureGauge); speedometer = new Speedometer(ui-&gt;dashFrame); horiz1-&gt;addWidget(tachometer); horiz1-&gt;addWidget(speedometer); horiz2-&gt;addWidget(fuelGauge); horiz2-&gt;addWidget(temperatureGauge); horiz2-&gt;addLayout(vertOPG); horiz2-&gt;addWidget(tripometer); horiz2-&gt;addWidget(odometer); // will NOT update when added to layout QVBoxLayout *vert1 = new QVBoxLayout(ui-&gt;dashFrame); vert1-&gt;addLayout(horiz1); vert1-&gt;addLayout(horiz2); this-&gt;ui-&gt;dashFrame-&gt;setLayout(vert1); } </code></pre> <p>I am perplexed that the other Widgets will update as expected, but not the object named tachometer. As I said before, if I don't add it to the layout, e.g.</p> <pre><code>// ... tachometer = new Tachometer(ui-&gt;dashFrame); // ... </code></pre> <p>it appears to work just fine. Furthermore, by debugging on the console I see that the RPM value for the tachometer is being sent to the appropriate slot that updates the view for the tachometer (I just noticed the tachometer finally responded to the update, but it isn't updating after every timeout as it should). It seems like some latency issues are clearly involved here. If anyone might have an idea as to why this might be, I would greatly appreciate some clarification.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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