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. Why doesn't ColumnView's PreviewWidget fill its container?
QtWS25 Last Chance

Why doesn't ColumnView's PreviewWidget fill its container?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 303 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.
  • B Offline
    B Offline
    Born Special
    wrote on last edited by Born Special
    #1

    I want the preview widget to automatically fill all the space in the column. I've tried setting layouts on everything. I've tried setting size policy. I can explicitly set the height of the QWidget, but it still doesn't adjust with the size of the window. Here's my code. Please help. Thanks.

    #include <QApplication>
    #include <QColumnView>
    #include <QMainWindow>
    #include <QStandardItemModel>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QMainWindow mainwindow;
        QColumnView columns;
        mainwindow.setCentralWidget(&columns);
        mainwindow.setGeometry(100,100,800,800);
    
        QStandardItemModel model;
        QStandardItem item("Item");
        model.appendRow(&item);
        columns.setModel(&model);
    
        QWidget previewpane;
        previewpane.setStyleSheet("background-color: red;");
        columns.setPreviewWidget(&previewpane);
    
        mainwindow.show();
        return a.exec();
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Which version of Qt are you using ?
      On which platform ?
      How did you install it ?

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

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Which version of Qt are you using ?
        On which platform ?
        How did you install it ?

        B Offline
        B Offline
        Born Special
        wrote on last edited by
        #3

        Qt 5.15.3 on Linux through Qt Creator.

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

          Which distribution ?
          Which desktop environment ?

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

          B 1 Reply Last reply
          0
          • SGaistS SGaist

            Which distribution ?
            Which desktop environment ?

            B Offline
            B Offline
            Born Special
            wrote on last edited by
            #5

            Arch. Openbox.

            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