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. Help with QFormLayout
QtWS25 Last Chance

Help with QFormLayout

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 8.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.
  • E Offline
    E Offline
    Exotic_Devel
    wrote on last edited by
    #3

    Ok, I found a part to set the maximum size of a QLineEdit is with setMaximumSize. Now what we have not figured out is how to define the size of the window unicial note that I am referring to the initial size, and no fixed size, the initial size is the size that the window should appear when vor call, but you can resize with mouse

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Exotic_Devel
      wrote on last edited by
      #4

      Anyone? :-(

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #5

        I don't know if i understand you correctly.

        maybe spacers are an option?

        could you show us a picture of what you want? and how it is now?

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Exotic_Devel
          wrote on last edited by
          #6

          I do not want to prevent resizing, I just want to open the window like the image that is edited, however if the user resizes it he can. Once this window is called it appears as the original image, notice that the window is narrow and all the fields appear the same size, the field "Estado" will be entered only where the abbreviations of the states, SP, MG, RS, etc.. .. Is the same size of the field "Nome" that you may receive up to 50 characters, is disproportionate. To solve the problem of the size of the fields I used setMaximumWidth (int) to set the maximum size (width) of the QLineEdit, but do not know if this is the correct way.
          What was I still could not make the open window as the size of the edited image. I edited the image resized with the mouse after it opened, but I want her to have open at that size. I've tried setSize setGeometry, without success.

          !http://forum.qtbrasil.com/download/file.php?id=67(Edited picture)!

          !http://forum.qtbrasil.com/download/file.php?id=66(Original Image)!

          Thanks for the help friend

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #7

            You could use a combination of setminimumsizehint and a spacer for each row except the biggest one.

            Like this (without the left part, to make my description simple):
            Row 1 : hlayout : nome + lineedit (setminimumsizehint = 50)
            Row 2 : hlayout :cep + linedi (setminimumsizehint = 15) + spacer
            row 3 ....
            .....

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • L Offline
              L Offline
              ludde
              wrote on last edited by
              #8

              Did you have a look at the fieldGrowthPolicy property?

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Exotic_Devel
                wrote on last edited by
                #9

                Actually what I need right now and set the initial window size. I'm trying to setGeometry, but ignores the window, perhaps because I'm using Layouts. I set the initial window size, but do not want to prevent the user can resize.
                For QLineEdits QLabels and am using QFormLayout. Below is a picture showing how to structure my layouts.

                !http://forum.qtbrasil.com/download/file.php?id=69(Structure Layout)!

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  ludde
                  wrote on last edited by
                  #10

                  What do you mean "ignores the window"? You should be able to set the geometry of the window, i.e. the widget that contains the top level layout. You should not use setGeometry on things inside a layout.

                  Of course, if the contents of the window does not allow the geometry you are setting it to, it will be as small/large is it can, but not exactly what you set it to.

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    Exotic_Devel
                    wrote on last edited by
                    #11

                    I am using setGeometry in the class constructor. But nothing changes.

                    1 Reply Last reply
                    0
                    • EddyE Offline
                      EddyE Offline
                      Eddy
                      wrote on last edited by
                      #12

                      i've made a simple ui file for you to look into :
                      "link ":http://dl.dropbox.com/u/33544011/dialog.ui

                      I followed the principle using spacers

                      hope this helps.

                      Qt Certified Specialist
                      www.edalsolutions.be

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        Exotic_Devel
                        wrote on last edited by
                        #13

                        Eddy, thanks for the example, but what I need now is to figure out how to set an initial size for the window.
                        I'm not using designer in this work, I am working on the arm.
                        I took a look at the code generated by the designer in the example you sent, but could not understand the code.

                        @class Ui_Dialog
                        {
                        public:
                        QGridLayout *gridLayout;
                        QListView *listView;
                        QVBoxLayout *verticalLayout;
                        QHBoxLayout *horizontalLayout;
                        QLabel *label;
                        QLineEdit *lineEdit;
                        QHBoxLayout *horizontalLayout_2;
                        QLabel *label_2;
                        QLineEdit *lineEdit_2;
                        QSpacerItem *horizontalSpacer;
                        QHBoxLayout *horizontalLayout_3;
                        QLabel *label_3;
                        QLineEdit *lineEdit_3;
                        QSpacerItem *horizontalSpacer_2;
                        QSpacerItem *verticalSpacer;

                        void setupUi(QDialog *Dialog)
                        {
                            if (Dialog->objectName().isEmpty())
                                Dialog->setObjectName(QString::fromUtf8("Dialog"));
                            Dialog->resize(475, 129);
                            gridLayout = new QGridLayout(Dialog);
                            gridLayout->setSpacing(6);
                            gridLayout->setContentsMargins(11, 11, 11, 11);
                            gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
                            listView = new QListView(Dialog);
                            listView->setObjectName(QString::fromUtf8("listView"));
                        
                            gridLayout->addWidget(listView, 0, 0, 1, 1);
                        
                            verticalLayout = new QVBoxLayout();
                            verticalLayout->setSpacing(6);
                            verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
                            horizontalLayout = new QHBoxLayout();
                            horizontalLayout->setSpacing(6);
                            horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
                            label = new QLabel(Dialog);
                            label->setObjectName(QString::fromUtf8("label"));
                        
                            horizontalLayout->addWidget(label);
                        
                            lineEdit = new QLineEdit(Dialog);
                            lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
                            lineEdit->setMinimumSize(QSize(0, 0));
                            lineEdit->setMaximumSize(QSize(16777215, 16777215));
                        
                            horizontalLayout->addWidget(lineEdit);
                        
                        
                            verticalLayout->addLayout(horizontalLayout);
                        
                            horizontalLayout_2 = new QHBoxLayout();
                            horizontalLayout_2->setSpacing(6);
                            horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
                            label_2 = new QLabel(Dialog);
                            label_2->setObjectName(QString::fromUtf8("label_2"));
                        
                            horizontalLayout_2->addWidget(label_2);
                        
                            lineEdit_2 = new QLineEdit(Dialog);
                            lineEdit_2->setObjectName(QString::fromUtf8("lineEdit_2"));
                            lineEdit_2->setMinimumSize(QSize(0, 0));
                        
                            horizontalLayout_2->addWidget(lineEdit_2);
                        
                            horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
                        
                            horizontalLayout_2->addItem(horizontalSpacer);
                        
                        
                            verticalLayout->addLayout(horizontalLayout_2);
                        
                            horizontalLayout_3 = new QHBoxLayout();
                            horizontalLayout_3->setSpacing(6);
                            horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));
                            label_3 = new QLabel(Dialog);
                            label_3->setObjectName(QString::fromUtf8("label_3"));
                        
                            horizontalLayout_3->addWidget(label_3);
                        
                            lineEdit_3 = new QLineEdit(Dialog);
                            lineEdit_3->setObjectName(QString::fromUtf8("lineEdit_3"));
                        
                            horizontalLayout_3->addWidget(lineEdit_3);
                        
                            horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
                        
                            horizontalLayout_3->addItem(horizontalSpacer_2);
                        
                        
                            verticalLayout->addLayout(horizontalLayout_3);
                        
                            verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
                        
                            verticalLayout->addItem(verticalSpacer);
                        
                        
                            gridLayout->addLayout(verticalLayout, 0, 1, 1, 1);
                        
                            gridLayout->setColumnStretch(1, 1);
                        
                            retranslateUi(Dialog);
                        
                            QMetaObject::connectSlotsByName(Dialog);
                        } // setupUi
                        

                        };

                        namespace Ui {
                        class Dialog: public Ui_Dialog {};
                        } // namespace Ui@

                        The class Ui_Dialog does not use inheritance, and sets the window size in QDialog object passed as parameter.
                        The correct way would be to inherit from QDialog?:

                        class Ui_Dialog : public QDialog

                        and set the window size in the constructor, by calling a resize (x, y)?

                        1 Reply Last reply
                        0
                        • EddyE Offline
                          EddyE Offline
                          Eddy
                          wrote on last edited by
                          #14

                          I don't understand what you want. you say you don't want to use ui but you ask how to use it?

                          I you want to understand how to use the ui file, then you can simply use the wizard to create a new widget based project with QDialog and everything is set up for you. copy paste and you're done.
                          If you search the docs the principle is well explained there.

                          to control the size of your window you could use resize:
                          @int main(int argc, char *argv[])
                          {
                          QApplication a(argc, argv);
                          Dialog w;

                          w.resize(300,300);
                          w.show();
                          
                          return a.exec();
                          

                          }@

                          Qt Certified Specialist
                          www.edalsolutions.be

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            Exotic_Devel
                            wrote on last edited by
                            #15

                            I did not ask how to use UI, I just tried to understand the code generated by the UI designer to be able to find the solution to my problem.
                            See my code up there is a class that inherits from QWidget and is displayed in a QMdiArea.

                            @void WindowMain::evoqueSubWindClientes()
                            {
                            QWidget *subwincli = new MdiChildClientes(this);
                            mdiarea->addSubWindow(subwincli);
                            subwincli->resize(800,600);
                            subwincli->show();
                            }@

                            But the command resize (800,600) does not have any effect.

                            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