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. QHBoxLayout cover QWidget with image

QHBoxLayout cover QWidget with image

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 521 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.
  • C Offline
    C Offline
    Craix0
    wrote on last edited by Craix0
    #1

    Hello, it's my first post here so thanks ahead for any help.
    I have a QWidget that hold image and QHBoxLayout that hold other componnents like QPushButton, QSlider etc..
    Next i'm try to add this to QDialog witch QHBoxLayout.
    I didn't got any warning or error, but in QDialog i only see part of Image. The other-half is covered by QHBoxLayout, i can see full picture only if i drag and move QDialog to full screen.

    I also add screenshot for beter explation.

    test.png

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi and welcome to the forums.
      Is that QHBoxLayout one of the red ones in Designer or did you make it all from code?

      It sounds like the dialog itself does not have a layout so it would auto-scale both the image and the "buttons" layout.

      C 1 Reply Last reply
      1
      • mrjjM mrjj

        hi and welcome to the forums.
        Is that QHBoxLayout one of the red ones in Designer or did you make it all from code?

        It sounds like the dialog itself does not have a layout so it would auto-scale both the image and the "buttons" layout.

        C Offline
        C Offline
        Craix0
        wrote on last edited by Craix0
        #3

        @mrjj
        "Is that QHBoxLayout one of the red ones in Designer or did you make it all from code?"

        All created dynamically in code

        "It sounds like the dialog itself does not have a layout so it would auto-scale both the image and the "buttons" layout."

        Probably no, i'm using QHLayout to organize everything in QDialog.

        (Simplificed example of code)

        /* create QButtons, QSpin etc.... */
        columnLayout = new QVBoxLayout;
        
        /* Adding button to QVBoxLayout... */
        
        widget = new QImageWidget;
        
        mainLayout = new QHBoxLayout();
        mainLayout->addWidget(widget);
        mainLayout->addLayout(columnLayout);
        
        /*seting up QDialog */
        
        windowWidget = new QDialog;
        windowWidget->setLayout(mainLayout);
        
        

        Note: Image Widget is my own clss that inherit from QWidget and override paintEvent to simply draw QImage.

        I also finded out that if i add QVBoxLayout to QWidget and then QWidget to QDialog instead of just adding QVBoxLayout to QDialog - it's working good. But still i would like to understand why simple QWidget dosnt work.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          It's most likely due to the QVBoxLayout and the size policy of the QImageWidget.
          You can try overriding sizeHint and return the size of the image.

          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