I have a Viewer contained inside a QFrame like this:
The white area is Viewer and grey area is QFrame.
What is want to have is another QscrollArea with the Viewer layed out vertically with a vertical splitter like this:
But even after selecting both QScrollArea and Viewer and then clicking the layout vertically in splitter button. The splitter does not appear? Any idea as to how to achieve this?
This is the answer you're looking for:
https://stackoverflow.com/a/28313475/1839954
On a not layed out area, add the children widgets, select them with CTRL key pressed and then lay them out using a vertical splitter (there's a button on the layout toolbar above the form preview)
Assuming that by "viewer" you mean a QListView for example, i had no problem to define this using Qt Designer. You should select the QFrame and the QScrollArea from the object inspector and then click on the vertical splitter layout inside Qt Designer.
Here is the result :
Here is my object inspector :
Hope this helps.
Related
I'm getting started with Qt and decided to build a full-screen text editor. I want to have a button (button with arrow in screenshot) attached to a QDockWidget which opens and closes it so the button is always visible to the right side of the screen and stay anchored to it when dock is visible or resized.
My current app is a simple fullscreen textEdit set to centeralwidget in Mainwindow.
I haven't found a way to do this yet with layouts or existing addAnchor() functions so any help or direction is appreciated.
You can achieve what you want by using a container for your text edit and the button. A QWidget instance can be used as an "invisible"*** container for other widgets.
So in Qt Designer you add a widget as a central widget of the main-window, inside this widget you add the text edit and the button, then you set a vertical layout for this container widget.
Don't forget to restrict the docking widget to only dock to the right side, you can do that with: dock->setAllowedAreas(Qt::DockWidgetArea::RightDockWidgetArea); //assuming dock is the pointer to your QDockWidget.
In case you want the dockWidget to be able to dock to any side and the button to follow, you can do that too, but it get a little bit more complicated. Basically you need to connect a slot to dockLocationChanged of your dockWidget and based on where it's docked you need to set-up a new layout for the container widget to be vertical or horizontal and the order of the textEdit and the button based on the side the dock happened.
LE:*** you will most likely need to set the margins you want, since both the widget and it's layout can have them and the actual content might have higher spacing than you want.
I've subclassed QStyle to control the aspect of my app. After customizing the aspect of the QLineEdits, I need to add an icon inside the QLineEdit and it has to be clickable by the user. I've seen that I can use the method QLineEdit::addAction to add an action and an icon in the QLineEdit. The problem arises with the position in which it draws the icon because as I have the customized QLineEdit, the icon draws too near the edge of QLineEdit. I need to separate more icon QLineEdit edge. Does anyone know how to control the position of the icon in the QLineEdit?
I want to create a UI which will have two seperator (which user will use them to resize objects) and will look like below.
I saw some examples, but they was all creating UI widgets/components with code, I have to do it with UI designer, but I can't.
Anything I try just causes strange UI look.
P.S. Red lines supposed to be splitter
P.S.S. I'm using QT Creator (QT 5.2)
-Select QTableWidget and the tabbed view, click Lay out vertically in splitter
-and than select QTreeWidget and only the splitter created earlier (you can select those easier in the right panel - hold Ctrl click the splitter and the treewidget - make sure you select only the splitter not the widgets that are inside it) and click Lay out horizontally in splitter
-and finally select the main-window itself and click Lay out vertically.
I am new to QT and I am creating a widget that has a gridlayout. The gridlayout contains a matrix of QLineEdit widgets. The window resizes to fit the layout but when layout is large it goes off screen. When I maximize the screen, the QLineEdit widgets are resized to fit the screen and for large layouts they become extremely small.
I want to be able to resize the window without resizing the QLineEdit widgets and add scroll bars to navigate.
I tried the following with no luck:
Window->resize(QSize(500,500));
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setWidget(Window);
where window is the widget containing the layout. Also, the window closes when after executing "scrollArea->setWidget(Window);" and I dont why.
If someone can help me out I would really appreciate it.
Thank You!
For disabling the vertical resize on the widgets, why don't you just use the setFixedHeight() method on the widgets?
For the menu bar, why don't you take it out of the widget that is scrollable. You can have a layout for the window that contains the menu bar and then the widget that contains everything else (scrollable part). Is that what you are looking for?
I fixed my problem by creating a QMainWindow with the menu bar. Then created a widget which includes the layout, set the Scroll Area to the widget. Finally set the central widget of the main widow to the scroll area.
Hello everyone, here is my code:
myplot *p = new myplot(gao.structpayloadgraph,
gao1.structpayloadgraph,
gao.structcol-2, "payload");
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setWidgetResizable(false);
p->resize(ui->scrollArea->size().width(), ui->scrollArea->size().height());
ui->scrollArea->setWidget(p);
I want p to take up the full available space of the scrollbar area and fit itself. However, the appearance looks 'squeezed' even though I called the resize function. What should I do to achieve the desired effect?
You have to treat the scroll area content widget as a normal QWidget. If you want automatic resize and you must use layouts in Qt. Try the following :
QVBoxLayout layout = new QVBoxLayout( ui->scrollAreaContent);
layout->setMargin(0);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
ui->scrollAreaContent->setLayout( layout);
layout->addWidget(p);
NOTE: ui->scrollAreaContent is a guess, but I think you are using ui files and default content widget is named like that ...
Go to the top right of the QT creator designer screen (Object, Class), right click on the QScrollArea row and select the "Lay Out" menu item, choose a layout (eg vertical or horizontal layout), make sure that your QWidget has a minimum or above size policy. Your scroll widget should now resize with the layout.