Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWidgte::setSizeIncrement() not have effect
Forum Updated to NodeBB v4.3 + New Features

QWidgte::setSizeIncrement() not have effect

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 642 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    giusdbg
    wrote on last edited by giusdbg
    #1

    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?

    C 1 Reply Last reply
    0
    • G giusdbg

      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?

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @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.

      G 1 Reply Last reply
      0
      • C ChrisW67

        @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.

        G Offline
        G Offline
        giusdbg
        wrote on last edited by giusdbg
        #3

        @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 just

        int 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.

        G 1 Reply Last reply
        0
        • G giusdbg

          @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 just

          int 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.

          G Offline
          G Offline
          giusdbg
          wrote on last edited by giusdbg
          #4

          @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);
             ..................................
          }
          
          G 1 Reply Last reply
          0
          • G giusdbg

            @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);
               ..................................
            }
            
            G Offline
            G Offline
            giusdbg
            wrote on last edited by giusdbg
            #5

            @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?

            G 1 Reply Last reply
            0
            • G giusdbg

              @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?

              G Offline
              G Offline
              giusdbg
              wrote on last edited by
              #6

              @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);
                  }
              }
              
              1 Reply Last reply
              0
              • G giusdbg has marked this topic as solved on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved