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. Grid layout reordering after modifications
Forum Updated to NodeBB v4.3 + New Features

Grid layout reordering after modifications

Scheduled Pinned Locked Moved Unsolved General and Desktop
gridlayoutwidgets
15 Posts 2 Posters 5.8k Views 2 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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 31 Jan 2016, 13:44 last edited by mrjj
    #4

    Im not sure its expecting anything. just seems to start with
    first Layoutitem and then then just position one by one.

    The number of rows seems to the height / items.
    if I set minimum height to such degree they can not longer fit with
    in layout_height, they start to overlap.

    Ahh. the hole is a "column"

    K 1 Reply Last reply 31 Jan 2016, 13:47
    0
    • M mrjj
      31 Jan 2016, 13:44

      Im not sure its expecting anything. just seems to start with
      first Layoutitem and then then just position one by one.

      The number of rows seems to the height / items.
      if I set minimum height to such degree they can not longer fit with
      in layout_height, they start to overlap.

      Ahh. the hole is a "column"

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 31 Jan 2016, 13:47 last edited by
      #5

      @mrjj
      Well not a whole column, but a single item in the grid. I could add more buttons to the layout for testing purposes, but since a picture is worth a thousand words, I think the link explains what's my issue quite well.

      Read and abide by the Qt Code of Conduct

      M 1 Reply Last reply 31 Jan 2016, 13:50
      0
      • K kshegunov
        31 Jan 2016, 13:47

        @mrjj
        Well not a whole column, but a single item in the grid. I could add more buttons to the layout for testing purposes, but since a picture is worth a thousand words, I think the link explains what's my issue quite well.

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 31 Jan 2016, 13:50 last edited by
        #6

        @kshegunov
        Yes pictures made it very clear.
        Try to reproduce it in Creator. Its seems to
        rearrange.

        K 1 Reply Last reply 31 Jan 2016, 13:53
        0
        • M mrjj
          31 Jan 2016, 13:50

          @kshegunov
          Yes pictures made it very clear.
          Try to reproduce it in Creator. Its seems to
          rearrange.

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 31 Jan 2016, 13:53 last edited by
          #7

          @mrjj
          Do you mean to make the form in the designer? Unfortunately, in this case this is not an option, see the linked thread for details as to why.

          Read and abide by the Qt Code of Conduct

          M 1 Reply Last reply 31 Jan 2016, 13:57
          0
          • K kshegunov
            31 Jan 2016, 13:53

            @mrjj
            Do you mean to make the form in the designer? Unfortunately, in this case this is not an option, see the linked thread for details as to why.

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 31 Jan 2016, 13:57 last edited by
            #8

            @kshegunov
            I know u cant use UI file.
            Im just wondering why in creator,
            if I create a grid 3x2 with buttons.
            Then from code, i take() and delete say button 3, i
            get no holes. But in AgDial there is.
            I should get the same, shouldn't I?

            K 1 Reply Last reply 31 Jan 2016, 13:59
            0
            • M mrjj
              31 Jan 2016, 13:57

              @kshegunov
              I know u cant use UI file.
              Im just wondering why in creator,
              if I create a grid 3x2 with buttons.
              Then from code, i take() and delete say button 3, i
              get no holes. But in AgDial there is.
              I should get the same, shouldn't I?

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 31 Jan 2016, 13:59 last edited by kshegunov
              #9

              @mrjj
              I suppose so. But I'm not takeing the item itself, maybe this is why the behavior differs. I'll try it out.
              Nope, substituting the relevant reinsertion code with:

              	delete layout->takeAt(index);
              	delete button;
              	buttons.erase(i);
              

              Produces the same hole. I have no idea why this works in your case ...

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 31 Jan 2016, 14:04 last edited by
                #10

                Just to be sure, we are talking
                about a normal gridlayout in a widget?
                At runtime, there should be no difference between one from
                UI files and one from code.
                So your case must be different or mine too simple.

                K 1 Reply Last reply 31 Jan 2016, 14:07
                0
                • M mrjj
                  31 Jan 2016, 14:04

                  Just to be sure, we are talking
                  about a normal gridlayout in a widget?
                  At runtime, there should be no difference between one from
                  UI files and one from code.
                  So your case must be different or mine too simple.

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 31 Jan 2016, 14:07 last edited by
                  #11

                  @mrjj

                  Just to be sure, we are talking
                  about a normal gridlayout in a widget?

                  Absolutely! Here's how a create a page:

                  bool AgDialPrivate::createPage(QAction * action)
                  {
                  	Q_ASSERT(action);
                  	QList<QAction *> children = action->findChildren<QAction *>(QString(), Qt::FindDirectChildrenOnly);
                  	if (children.count() <= 0 || pages.value(action, NULL))
                  		return false;
                  
                  	// Create a page for this action
                  	AGUI_Q(AgDial);
                  
                  	QWidget * page = new QWidget(q);
                  	new QGridLayout(page);
                  
                  	pages.insert(action, page);
                  	q->addWidget(page);
                  
                  	// Create a return button
                  	QAction * parent = qobject_cast<QAction *>(action->parent());
                  	createReturnButton(page, parent);
                  
                  	// If the action has any children, create their buttons and/or pages
                  	foreach (QAction * child, children)  {
                  		createButton(child);
                  		if (child->children().count() > 0)
                  			createPage(child);
                  	}
                  
                  	// Map the triggered signal of the child action
                  	QSignalMapper * mapper = new QSignalMapper(page);
                  	mapper->setMapping(action, page);
                  	QObject::connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
                  	QObject::connect(mapper, SIGNAL(mapped(QWidget *)), q, SLOT(setCurrentWidget(QWidget *)));
                  
                  	return true;
                  }
                  

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 31 Jan 2016, 14:09 last edited by
                    #12

                    Ok, i delete sample and tried again.
                    Now I get hole too! ?
                    only difference is that I had min/max heights in other test.

                    K 1 Reply Last reply 31 Jan 2016, 14:12
                    0
                    • M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 31 Jan 2016, 14:12 last edited by
                      #13

                      Ok. now even in Creator it leaves holes.
                      my first sample must not been proper.

                      1 Reply Last reply
                      0
                      • M mrjj
                        31 Jan 2016, 14:09

                        Ok, i delete sample and tried again.
                        Now I get hole too! ?
                        only difference is that I had min/max heights in other test.

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 31 Jan 2016, 14:12 last edited by
                        #14

                        @mrjj said:

                        only difference is that I had min/max heights in other test.

                        Maybe the layout's redistribution of item space had hidden the effect in the previous test? I couldn't think of another reason.

                        Read and abide by the Qt Code of Conduct

                        M 1 Reply Last reply 31 Jan 2016, 14:15
                        0
                        • K kshegunov
                          31 Jan 2016, 14:12

                          @mrjj said:

                          only difference is that I had min/max heights in other test.

                          Maybe the layout's redistribution of item space had hidden the effect in the previous test? I couldn't think of another reason.

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 31 Jan 2016, 14:15 last edited by mrjj
                          #15

                          @kshegunov
                          I agree . must been something like that as now the effect
                          is 100% as your experience. Even in designer.
                          Sorry for the confusion.

                          1 Reply Last reply
                          1

                          13/15

                          31 Jan 2016, 14:12

                          • Login

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