QWidgte::setSizeIncrement() not have effect
-
Hi.
In a (quite complex) project for kde5 + qt5 the setSizeIncrement() property has no effect.
In the same project but for kde4 + qt4 setSizeIncrement() works.
In a simple test with Qt Creator for qt5 setSizeIncrement() works.
All on the same system and under the same conditions.
Does anyone know what to check, try, have a workaround, a solution?
-
Hi.
In a (quite complex) project for kde5 + qt5 the setSizeIncrement() property has no effect.
In the same project but for kde4 + qt4 setSizeIncrement() works.
In a simple test with Qt Creator for qt5 setSizeIncrement() works.
All on the same system and under the same conditions.
Does anyone know what to check, try, have a workaround, a solution?
@giusdbg We will guess that you mean QWidget::setSizeIncrement() and that you read the warning.
KDE 4 and KDE 5 have different window managers, so this can easily account for the difference from option 1 to 2. There may also be difference between Qt 4 and 5 implementations (though the warning is the same).
Your first and third option are the same, assuming both KDE 5, and yet you claim the behaviour is different. Without a minimal, compilable example there's not much else to say.
-
@giusdbg We will guess that you mean QWidget::setSizeIncrement() and that you read the warning.
KDE 4 and KDE 5 have different window managers, so this can easily account for the difference from option 1 to 2. There may also be difference between Qt 4 and 5 implementations (though the warning is the same).
Your first and third option are the same, assuming both KDE 5, and yet you claim the behaviour is different. Without a minimal, compilable example there's not much else to say.
@ChrisW67 Yes, i agree.
It's hard to give a simple and useful example, because it's all handled internally by kde and qt, there's justint main(int argc, char *argv[]) { QApplication a (argc, argv); KDBusService service(KDBusService::Unique); LMSensorsDock *ksensors= new LMSensorsDock(); a.setQuitOnLastWindowClosed(false); return a.exec(); ........................................................... // click on menu run (with parent = 0) ........................................................... LMSensorsWidget::LMSensorsWidget (QWidget *parent) : QWidget( parent, Qt::WindowStaysOnTopHint) { setAttribute( Qt::WA_DeleteOnClose ); setSizeIncrement(64,64);
For X11 there is a trick
// make windowHandle() find struct QTLWExtra -> QWidgetWindow *window not set to zero WId qwid = winId();
It doesn't work in Wyland.
(currently I have no idea, unfortunately we have to dig into the idiosyncrasies and peculiarities of the various systems involved, (and Wyland even after many years of development still has some annoying ones.))Or solve the jerky scaling problem in a whole other way.
-
@ChrisW67 Yes, i agree.
It's hard to give a simple and useful example, because it's all handled internally by kde and qt, there's justint main(int argc, char *argv[]) { QApplication a (argc, argv); KDBusService service(KDBusService::Unique); LMSensorsDock *ksensors= new LMSensorsDock(); a.setQuitOnLastWindowClosed(false); return a.exec(); ........................................................... // click on menu run (with parent = 0) ........................................................... LMSensorsWidget::LMSensorsWidget (QWidget *parent) : QWidget( parent, Qt::WindowStaysOnTopHint) { setAttribute( Qt::WA_DeleteOnClose ); setSizeIncrement(64,64);
For X11 there is a trick
// make windowHandle() find struct QTLWExtra -> QWidgetWindow *window not set to zero WId qwid = winId();
It doesn't work in Wyland.
(currently I have no idea, unfortunately we have to dig into the idiosyncrasies and peculiarities of the various systems involved, (and Wyland even after many years of development still has some annoying ones.))Or solve the jerky scaling problem in a whole other way.
@giusdbg It seems that some things cannot be done in wayland, or at least it is complicated and not certain.
If some clean solution doesn't emerge, I think I'll try use the resize event and then adjust the size of the widget to the nearest snap point.
void LMSensorsWidget::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); .................................. }
-
@giusdbg It seems that some things cannot be done in wayland, or at least it is complicated and not certain.
If some clean solution doesn't emerge, I think I'll try use the resize event and then adjust the size of the widget to the nearest snap point.
void LMSensorsWidget::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); .................................. }
@giusdbg I've started experimenting with manually implementing the step resize.
From what I've seen there's no working way to detect when the user is done resizing (released the button on the window border), so all that's left is to use a timer in the resize event.
But using a timer in the resize event to trigger code-forced resize, if the user holds down the button for a long time during the resize, the mask on screen doesn't assume the size of the code-forced resize, which qt uses internally instead and report.
Is there a way to know the size, real, graphic, of the mask?
-
@giusdbg I've started experimenting with manually implementing the step resize.
From what I've seen there's no working way to detect when the user is done resizing (released the button on the window border), so all that's left is to use a timer in the resize event.
But using a timer in the resize event to trigger code-forced resize, if the user holds down the button for a long time during the resize, the mask on screen doesn't assume the size of the code-forced resize, which qt uses internally instead and report.
Is there a way to know the size, real, graphic, of the mask?
@giusdbg In wayland there are various things that are complicated or impossible to fix, I decided for this trick
int main(int argc, char *argv[]) { if (!qEnvironmentVariableIsSet ( "QT_QPA_PLATFORM" )) qputenv( "QT_QPA_PLATFORM", "xcb" );
If anyone cares about the code that was trying to handle the jerky resize manually this is it (it doesn't work badly, but it doesn't have stable behavior and throws an infinite resize->timer->resize event loop)
qtResize.setSingleShot(true); connect(&qtResize, SIGNAL(timeout()), this, SLOT(resizeDone())); ........................ bool LMSensorsWidget::event(QEvent *event) { // qDebug() << "\033[91m" << "qDebug(): LMSensorsWidget::event event->type()" << event->type() <<"\033[0m"; switch (event->type()) { case QEvent::NonClientAreaMouseButtonRelease: // resize (size()); break; case QEvent::Resize: /* if (event->spontaneous()) return false; */ case QEvent::UpdateRequest: qtResize.stop(); qtResize.start(500); break; default: break; } return QWidget::event (event); } void LMSensorsWidget::resizeDone() { QSize qsResize, qsSnap, qsObj; QRect qrGeom; qsResize = size(); qsSnap.setWidth(int((qsResize.width() / 64.0) + 0.5) * 64.0); qsSnap.setHeight(int((qsResize.height() / 64.0) + 0.5) * 64.0); // if (qsSnap != qsResize) { resize(qsResize.width(), qsResize.height() -1); resize(qsSnap); } }
-