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. [SOLVED] QFormLayout not applied correctly
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QFormLayout not applied correctly

Scheduled Pinned Locked Moved General and Desktop
12 Posts 2 Posters 3.0k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    1. What do you mean by it doesn't apply ? You are adding a widget to like you would in e.g. a QVBoxLayout so there's nothing wrong here.

    2. The problem with icons is that you only have "centralized" icons on Linux, to my knowledge there's no equivalent for Windows or OS X

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

    K 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      1. What do you mean by it doesn't apply ? You are adding a widget to like you would in e.g. a QVBoxLayout so there's nothing wrong here.

      2. The problem with icons is that you only have "centralized" icons on Linux, to my knowledge there's no equivalent for Windows or OS X

      K Offline
      K Offline
      kdev
      wrote on last edited by kdev
      #3

      @SGaist

      1. The added QTableWidget doesn't fill the whole QTabWidget as you can see in the screenshot above.
      2. I don't want anymore to use icon files.
        I want that the icons ( such as cut, copy, paste, undo, redo ... ) inside the QToolBar will be loaded differently as desktop-environment specific, for example I want it to change to KDE icons because I'm on KDE, and to Windows icons when I'm on Windows. What should I do in this case, if I want to use the code rather than icon files ?
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4
        1. Generally, you have some margin/spacing that application follows.

        2. That's what I wrote before: OS X and Windows don't have the concept of centralized icon pools.

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

        K 1 Reply Last reply
        0
        • SGaistS SGaist
          1. Generally, you have some margin/spacing that application follows.

          2. That's what I wrote before: OS X and Windows don't have the concept of centralized icon pools.

          K Offline
          K Offline
          kdev
          wrote on last edited by kdev
          #5

          @SGaist

          1. So, what do you suggest concerning this issue, inside the code?
          2. So what I should do for those 2 operating systems is using icon files, right ?
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6
            1. Change the margin and spacing but first, why a QFormLayout if you don't use the features from that layout ?
            2. That's what cross-platform application usually do: ship the icons with the application (beware the licensing of the icon you are using)

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

            K 1 Reply Last reply
            1
            • SGaistS SGaist
              1. Change the margin and spacing but first, why a QFormLayout if you don't use the features from that layout ?
              2. That's what cross-platform application usually do: ship the icons with the application (beware the licensing of the icon you are using)
              K Offline
              K Offline
              kdev
              wrote on last edited by kdev
              #7

              @SGaist

              1. the problem doesn't got solved, even I tried the following code:
              tw = new QTabWidget;
                      QFormLayout * fl = new QFormLayout;
                      fl->setContentsMargins(0, 0, 0, 0);
                      fl->setSpacing(0);
                      tw->setLayout(fl);
              
              1. Ok, I will keep using the GNOME icons.
              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Why are you setting the layout on the QTabWidget ? QTabWidget is a container widget, you should put widgets in it, not use layout on it.

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

                K 1 Reply Last reply
                0
                • SGaistS SGaist

                  Why are you setting the layout on the QTabWidget ? QTabWidget is a container widget, you should put widgets in it, not use layout on it.

                  K Offline
                  K Offline
                  kdev
                  wrote on last edited by
                  #9

                  @SGaist How this can be done? can you give me an example?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10
                    QTabWidget *myTabWidget = new QTabWidget;
                    QTableWidget *myTableWidget = new QTableWidget;
                    myTabWidget->addTab(myTableWidget, tr("TableWidget"));
                    

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

                    K 1 Reply Last reply
                    0
                    • SGaistS SGaist
                      QTabWidget *myTabWidget = new QTabWidget;
                      QTableWidget *myTableWidget = new QTableWidget;
                      myTabWidget->addTab(myTableWidget, tr("TableWidget"));
                      
                      K Offline
                      K Offline
                      kdev
                      wrote on last edited by kdev
                      #11

                      @SGaist Thanks anyway, but that didn't solve my problem: because what I want here is adding a tablewidget inside tabwidget container, with the possibility of adding other widgets inside the tabwidget. Finally, I found the solution by myself through using QGridLayout instead of QFormLayout(which was the misleading way): now it works perfectly.

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

                        I'd recommend to reanalyze your widget creation handling. It looks like you are slowly creating a labyrinth of QWidgets in other QWidgets in QTabWidget contained in other QTabWidget maybe contained in QTabWidget. The complexity of the widgets themselves are not really the problem, but the building of the elements seems to take a complex road that should be cleaned a bit.

                        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
                        0

                        • Login

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