I'm having trouble registering for starter an event in a scrollarea with a Qcustomplot for its widget. I tried install an event filter, but it seems that it works in other scroll area, except its own scroll area. Any advice on fixing this / registering or filtering the event in the qcustomplot/scrollarea? attached is my cpp and the ui...
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qcustomplot.h"
#include <QWidget>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget plotWidget;
QCustomPlot* customPlot = new QCustomPlot;
int x = ui->plotArea_SA->width();
int y = ui->plotArea_SA->height();
for(int i = 0; i < 100; i++)
{
customPlot->plotLayout()->insertRow(i);
QCPAxisRect *ar = new QCPAxisRect(customPlot);
ar->setMinimumSize(x, y);
customPlot->plotLayout()->addElement(i, 0, ar);
}
customPlot->setMinimumWidth(1800);
customPlot->installEventFilter(this);
this->setWindowState(Qt::WindowMaximized);
ui->plotArea_SA->setWidget(customPlot);
qInfo() << ui->plotArea_SA->verticalScrollBar()->value();
ui->plotArea_SA->widget()->installEventFilter(this);
ui->plotArea_SA->viewport()->installEventFilter(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
bool MainWindow::eventFilter(QObject* /*obj*/, QEvent* evt)
{
if (evt->type() == QEvent::Wheel)
{
// ignore the event (this effectively
// makes it "skip" one object)
evt->ignore();
}
// return false to continue event propagation
// for all events
return false;
}
void MainWindow::wheelEvent(QWheelEvent* event)
{
int numDegrees = event->delta() / 8;
qInfo() << numDegrees;
ui->plotArea_SA->verticalScrollBar()->setValue(ui->plotArea_SA->verticalScrollBar()->value() - numDegrees);
qInfo() << "got here";
event->accept();
}
and the UI
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1214</width>
<height>638</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QScrollArea" name="searchTable_SA">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>298</width>
<height>279</height>
</rect>
</property>
<zorder>displayTable_SA</zorder>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QScrollArea" name="displayTable_SA">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>298</width>
<height>278</height>
</rect>
</property>
<zorder>searchTable_SA</zorder>
</widget>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<widget class="QScrollArea" name="plotArea_SA">
<property name="minimumSize">
<size>
<width>0</width>
<height>90</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="widgetResizable">
<bool>false</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<height>1000</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1000</width>
<height>1000</height>
</size>
</property>
<zorder>displayTable_SA</zorder>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1214</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
Related
I'm trying to port my project from Qt5 to Qt6.
My problem is that UIC generated code looks like this:
QObject::connect(SelectHome, &QToolButton::clicked, toQPSQLSettingUI, qOverload<>(&QWidget::selectHome));
MSVC2019 compilations fails with:
ui_toqpsqlsettingui.h(74,101): error C2039: 'selectHome': is not a member of 'QWidget'
C:\Qt\6.0.4\msvc2019_64\include\QtWidgets\qcompleter.h(57): message : see declaration of 'QWidget'
C:\Users\I542264\source\repos\tora\src\ui_toqpsqlsettingui.h(74,1): error C2065: 'selectHome': undeclared identifier
See the target is method is QWidget::selectHome, so IMHO MSVC is right: QWidget does not have method selectHome. But target should be sub-class method toQPSQLSettingUI::selectHome
Complete source is here. Initially created for Qt2, migrated to Qt3=>Qt4=>Q5.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>toQPSQLSettingUI</class>
<widget class="QWidget" name="toQPSQLSettingUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>517</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form1</string>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="PGSQL_HOME"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="TextLabel6_2_2_2">
<property name="toolTip">
<string>The default dateformat to use when querying the database.</string>
</property>
<property name="text">
<string>PgSQL home</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>PGSQL_HOME</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="SelectHome">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>PGSQL_HOME</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>SelectHome</sender>
<signal>clicked()</signal>
<receiver>toQPSQLSettingUI</receiver>
<slot>selectHome()</slot>
<hints>
<hint type="sourcelabel">
<x>606</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>314</x>
<y>258</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<signal>signal1()</signal>
</slots>
</ui>
I'm not sure if this is a bug or the way QT Designer was designed but I cannot resize any element on a QT widget with the 'blue boxes' one would expect to resize with. I also am not allowed to edit the minimum/maximum sizes to anything but zero. Are there some settings I need to change or is this just a bug?
.UI file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MeshGeneratorWidget</class>
<widget class="QWidget" name="MeshGeneratorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>927</width>
<height>789</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Mesh Generator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="AlignmentSceneviewerWidget" name="sceneviewer_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QDockWidget" name="dockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>-10</y>
<width>492</width>
<height>771</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>492</width>
<height>557</height>
</size>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::AllDockWidgetAreas</set>
</property>
<property name="windowTitle">
<string>Control Panel</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>388</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="time_groupBox">
<property name="title">
<string>Time:</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="timeValue_doubleSpinBox">
<property name="maximum">
<double>12000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="timeLoop_checkBox">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="timeValue_label">
<property name="text">
<string>Time value:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="timePlayStop_pushButton">
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>234</height>
</size>
</property>
<property name="title">
<string>Adjust Data</string>
</property>
<widget class="QSlider" name="adjustData_Slider">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>431</width>
<height>22</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="minimum">
<number>-200</number>
</property>
<property name="maximum">
<number>200</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>410</x>
<y>70</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>+2s</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>-2s</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>60</x>
<y>170</y>
<width>201</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>View data with video</string>
</property>
</widget>
<widget class="QPushButton" name="viewVideo_button">
<property name="geometry">
<rect>
<x>180</x>
<y>90</y>
<width>121</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>View Video</string>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="video_groupBox">
<property name="title">
<string>Video:</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="frameIndex_label">
<property name="text">
<string>Frame index:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="framesPerSecond_spinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="frameIndex_spinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="framesPerSecond_label">
<property name="text">
<string>Frames per second:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QFrame" name="numFrames_frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="numFrames_label">
<property name="text">
<string># frames:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="numFramesValue_label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>200</x>
<y>0</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="blackfynn_groupBox">
<property name="title">
<string>Blackfynn:</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="6" column="2">
<widget class="QPushButton" name="downloadData_button">
<property name="text">
<string>Download Data</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QPushButton" name="blackfynnTimeSeries_pushButton">
<property name="toolTip">
<string>Retrieve time series</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/meshgeneratorstep/images/download-icon-blue.png</normaloff>:/meshgeneratorstep/images/download-icon-blue.png</iconset>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLineEdit" name="exportDirectory_lineEdit">
<property name="text">
<string>C:\Users\jkho021\Projects\MPB</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Export for WebGL</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="blackfynnDatasets_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="blackfynnDatasets_label">
<property name="text">
<string>Datasets:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="blackfynnDatasets_pushButton">
<property name="toolTip">
<string>Retrieve datasets</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/meshgeneratorstep/images/download-icon-blue.png</normaloff>:/meshgeneratorstep/images/download-icon-blue.png</iconset>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QComboBox" name="blackfynnTimeSeries_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="blackfynnTimeSeries_label">
<property name="text">
<string>Time series:</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Upload to Blackfynn</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="blackfynnProfiles_groupBox">
<property name="title">
<string>Profiles:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="profiles_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addProfile_pushButton">
<property name="toolTip">
<string>Add profile</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/meshgeneratorstep/images/plus-icon-green-th.png</normaloff>:/meshgeneratorstep/images/plus-icon-green-th.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPushButton" name="viewAll_button">
<property name="text">
<string>View All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="done_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AlignmentSceneviewerWidget</class>
<extends>QWidget</extends>
<header>opencmiss/zincwidgets/alignmentsceneviewerwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
Not a bug. As ekhumoro mentioned above, you can't resize widgets that are contained in a layout (not with Designer, anyway). You need to break the layout, then resize, then reapply the layout. Kind of a pain, I know, but after awhile you get used to it. The toolbar buttons make this go a lot faster, BTW.
My colleague created a C++ Qt Project on Linux and I "transposed" it on Windows. Now, I am a functional GUI but I don't know why, when I open the .ui file with QtDesigner, the file is empty, all widgets disappeared.
Any idea how to get back my widgets or is it only because the file was created on QtDesigner on Linux ?
Here is a part of the ui file opened on Windows with a text editor:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>874</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>541</width>
<height>331</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>860</width>
<height>700</height>
</size>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="buildMotionTab_3">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<widget class="QFrame" name="centralFrame_3">
<property name="geometry">
<rect>
<x>-10</x>
<y>0</y>
<width>860</width>
<height>851</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>860</width>
<height>851</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>810</width>
<height>851</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QFrame" name="motorFrameP_3">
<property name="geometry">
<rect>
<x>260</x>
<y>10</y>
<width>281</width>
<height>280</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>280</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>280</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QSpinBox" name="LineDist">
<property name="geometry">
<rect>
<x>190</x>
<y>150</y>
<width>81</width>
<height>32</height>
</rect>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>470</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
[...]
<widget class="QPushButton" name="StandDownButton">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>StandDown</string>
</property>
</widget>
<widget class="QPushButton" name="Homing1Button">
<property name="geometry">
<rect>
<x>120</x>
<y>70</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Homing X</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>874</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
Looks like some thing went wrong in transporting the file (I can't say, but could be copy was done in binary mode? or some lines were not expanded in case you copied and pasted the text ..)
The ui xml you shared is broken at line 127 where it shows [...] which is not valid, in place of this it should show closing xml tags for </widget> , I think 4 closing tags </widget> are missing, then it should be ok.
I have an issue with getting a QTreewidget full height inside a QFormLayout. I'm on Windows 10 and use QT 5.7
Things I tried:
all possible Vertical policy's without success. Change the
FieldGrowthPolicy of the layout to AllNonFixedFieldsGrow
Use another widget, all fail to make this work
That's all the options I found to possibly make this work.
Here's what I try to achieve:
Here's my ui file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>747</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Please grow the treeview:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QTreeWidget" name="treeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Please read the Qt tutorials about layouts.
I added a two layouts and a spacer to your ui file.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>489</width>
<height>215</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Please grow the treeview:</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Based on this answer: Qt formlayout not expanding qplaintextedit vertically which worked for me, setting the Vertical Stretch attribute to something other than 0 should do the trick.
So i have a small program i've made with Qt Designer, and for the most part, it's completely fine. But there is one niggling problem;
I have a QLabel, for which the text is sometimes too long, so i want to make the text wrap. This should be a simple task.
Here is what it looks like with no wordwrap
And this is fine. But when the text gets too long, it puts in a horrible scroll bar. I don't want this, so i enable wordwrap. But then this happens:
Which at first i thought was just Qt Designer being crap, so compiled and run hoping it would go away. Sometimes this happens, so i thought it was a reasonable assumption.
It wasn't.
Why the hell is this happening?!
EDIT: enabling word wrap manually in the widget initialiser also causes the same behaviour - so it's not caused by Qt Designer, it's an issue elsewhere. Any help would be greatly appreciated!
Here is the content of the UI file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>705</width>
<height>347</height>
</rect>
</property>
<property name="windowTitle">
<string>Title</string>
</property>
<property name="windowIcon">
<iconset resource="icons.qrc">
<normaloff>:/icons/icons/3/bonus48x48_20.png</normaloff>:/icons/icons/3/bonus48x48_20.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,1">
<item row="1" column="0">
<widget class="QLabel" name="label_molecule">
<property name="text">
<string>Molecule:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_molecule"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QToolBox" name="toolBox_modelDetails">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_isomer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<height>154</height>
</rect>
</property>
<attribute name="label">
<string>Isomer</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget_isomers">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_model">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>357</width>
<height>231</height>
</rect>
</property>
<attribute name="label">
<string>Model</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0">
<item>
<widget class="QListWidget" name="listWidget_models">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<stylestrategy>PreferDefault</stylestrategy>
</font>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_description">
<property name="text">
<string>Howdy!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_basisSet">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<height>154</height>
</rect>
</property>
<attribute name="label">
<string>Basis Set</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="listWidget_basisSets">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="3" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_buttons">
<item>
<spacer name="horizontalSpacer_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_save">
<property name="text">
<string>Save Input File</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_open">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2" rowspan="2">
<widget class="QGroupBox" name="groupBox_MoleculeViewer">
<property name="title">
<string>Molecule</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources>
<include location="icons.qrc"/>
</resources>
<connections/>
</ui>
QLabel in combination with word wrap and Layouts give some funny behaviour.
See https://bugreports.qt.io/browse/QTBUG-37673.
Why are you nesting your widgets (the QLabel and the QListWidget) into a QWidget?
That's why you are getting two scrollbars. One from the QListWidget, because it has more items than can be viewed. And one for the parent QWidget.
You should be using layouts.
This is what you have:
Should be something like this: