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. Info about some technics in Qt

Info about some technics in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 2.4k Views
  • 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by
    #1

    Hi! I want to know:

    1. How to make QSizeGrip placed to the right bottom corner?
    2. How to make the context menu available to the full application?

    Thanks in advance.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      patrik08
      wrote on last edited by patrik08
      #2

      Inside zip from https://github.com/pehohlva/Tiny_Edit/tree/master/tests
      is a sample from a QCommandLinkButton only swap to normal button ...

        _EpubStart = new StartMenuButton();
          _EpubStart->setMenu(menuTocEpub);
          statusBar()->addWidget(_EpubStart);
          statusBar()->setSizeGripEnabled(false);
      

      0_1505034684465_menuepub.png

      Limit QMenu in one time to display is 30 pieces...

      Cobra91151C 1 Reply Last reply
      0
      • P patrik08

        Inside zip from https://github.com/pehohlva/Tiny_Edit/tree/master/tests
        is a sample from a QCommandLinkButton only swap to normal button ...

          _EpubStart = new StartMenuButton();
            _EpubStart->setMenu(menuTocEpub);
            statusBar()->addWidget(_EpubStart);
            statusBar()->setSizeGripEnabled(false);
        

        0_1505034684465_menuepub.png

        Limit QMenu in one time to display is 30 pieces...

        Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by
        #3

        @patrik08

        Hi! Thanks, but I don't have QStatusBar to display QSizeGrip.

        I have added QSizeGrip to QGridLayout:

        QSizeGrip *sizeGrip = new QSizeGrip(this);
        QGridLayout *sizeGripLayout = new QGridLayout();
        sizeGripLayout->setContentsMargins(QMargins());
        sizeGripLayout->setSpacing(0);
        sizeGripLayout->addWidget(sizeGrip, 0, 0, 1, 1, Qt::AlignBottom | Qt::AlignRight);
        

        and add QGridLayout to QVBoxLayout (main layout).

        0_1505035408511_2017-09-10_122259.png

        But it adds to much space at the bottom.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          patrik08
          wrote on last edited by
          #4

          Or any QWidget have
          http://doc.qt.io/qt-4.8/qwidget.html#contextMenuPolicy-prop
          to place menu..

          QDialog *dialog = new QDialog(0, Qt::FramelessWindowHint);
          QVBoxLayout *layout = new QVBoxLayout(dialog);
          
          // To remove any space between the borders and the QSizeGrip...      
          layout->setContentsMargins(QMargins());         
          // and between the other widget and the QSizeGrip
          layout->setSpacing(0);
          layout->addWidget(new QTextEdit(dialog));
          
          // The QSizeGrip position (here Bottom Right Corner) determines its
          // orientation too
          layout->addWidget(new QSizeGrip(dialog), 0, Qt::AlignBottom | Qt::AlignRight);
          
          dialog->show();
          
          Cobra91151C 1 Reply Last reply
          1
          • P patrik08

            Or any QWidget have
            http://doc.qt.io/qt-4.8/qwidget.html#contextMenuPolicy-prop
            to place menu..

            QDialog *dialog = new QDialog(0, Qt::FramelessWindowHint);
            QVBoxLayout *layout = new QVBoxLayout(dialog);
            
            // To remove any space between the borders and the QSizeGrip...      
            layout->setContentsMargins(QMargins());         
            // and between the other widget and the QSizeGrip
            layout->setSpacing(0);
            layout->addWidget(new QTextEdit(dialog));
            
            // The QSizeGrip position (here Bottom Right Corner) determines its
            // orientation too
            layout->addWidget(new QSizeGrip(dialog), 0, Qt::AlignBottom | Qt::AlignRight);
            
            dialog->show();
            
            Cobra91151C Offline
            Cobra91151C Offline
            Cobra91151
            wrote on last edited by Cobra91151
            #5

            @patrik08

            Ok. I have changed code to:

            QVBoxLayout *sizeGripLayout = new QVBoxLayout();
            sizeGripLayout->setContentsMargins(QMargins());
            sizeGripLayout->setSpacing(0);
            sizeGripLayout->addWidget(new QSizeGrip(mainWindow), 0, Qt::AlignBottom | Qt::AlignRight); //mainWindow - QWidget
            

            But the same extra space exists at the bottom:
            0_1505037499023_2017-09-10_125728.png

            Also, I have context menu in contextMenuEvent for example in A how to extend it to B? Setting this->setContextMenuPolicy(Qt::CustomContextMenu); at B will not display the context menu from A. Do I need to create the global class to manage context menu everywhere?

            1 Reply Last reply
            0
            • Cobra91151C Offline
              Cobra91151C Offline
              Cobra91151
              wrote on last edited by Cobra91151
              #6

              In QHBoxLayout I have set setContentsMargins(10, 10, 10, 0); - bottom to 0, so:

              0_1505038728294_2017-09-10_131836.png

              I think, it's better, but one problem, when application is maximized, there is no space at the bottom. Should I change setContentsMargins at event or there is other solution?

              1 Reply Last reply
              0
              • P Offline
                P Offline
                patrik08
                wrote on last edited by
                #7

                Debug your item for margin and cast element so:

                     QObjectList mx = this->children();
                      QList<QObject*>::const_iterator x;
                      for (x = mx.constBegin(); x != mx.constEnd(); ++x) {
                        QObject *fox = *x;
                           qDebug() << "name:" << fox->objectName();
                           QWidget *vox = qobject_cast<QWidget *>(fox);
                           if (vox) {
                              qDebug() << "size element:" << vox->size() << ":" << vox->accessibleName();
                
                           }
                      }
                
                Cobra91151C 1 Reply Last reply
                0
                • P patrik08

                  Debug your item for margin and cast element so:

                       QObjectList mx = this->children();
                        QList<QObject*>::const_iterator x;
                        for (x = mx.constBegin(); x != mx.constEnd(); ++x) {
                          QObject *fox = *x;
                             qDebug() << "name:" << fox->objectName();
                             QWidget *vox = qobject_cast<QWidget *>(fox);
                             if (vox) {
                                qDebug() << "size element:" << vox->size() << ":" << vox->accessibleName();
                  
                             }
                        }
                  
                  Cobra91151C Offline
                  Cobra91151C Offline
                  Cobra91151
                  wrote on last edited by
                  #8

                  @patrik08

                  Thanks, but I have changed Qt event and the problem with QSizeGrip has been fixed. The only think now is to create global menu.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi,

                    Do you mean QMainWindow's menuBar ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • Cobra91151C Offline
                      Cobra91151C Offline
                      Cobra91151
                      wrote on last edited by
                      #10

                      I have fixed all issues. Thank you.

                      1 Reply Last reply
                      0

                      • Login

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