Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

manipulate the position of a tableview with an xml file



  • Hi,

    I'm new in Qt and C++ and need some help.
    I have created some tableviews with the designer.
    Now i want to make it possible to change the position and the size of the tables with an xml file.

    This is my xml file so far.

    <?xml version="1.0" encoding="UTF-8"?>
    <manupulateUi>
    	<class>test_screen</class>
    	<widget class="QMainWindow" name"test_screen">
    		<widget class="QWidget" name="centralWidget">
    			<widget class="QLabel" name="label_2">
    				<property name="geometry">
    					<rect>
    						<x>830</x>
    						<y>10</y>
    					</rect>
    				</property>
    			</widget>
    		</widget>
    	</widget>
    </manupulateUi>
    

    Is that possible?
    Some example code for the explanation would be very helpful for me.

    Thank you.


  • Lifetime Qt Champion

    @Mogli123 Sure it is possible. Don't put these tableviews into a layout and position/size them manually.
    You can find here examples for reading XML: http://doc.qt.io/qt-5/examples-xml.html



  • Thank you for your answer.

    Is my xml the right way to manage that?
    I'm not sure how to get the information from the xml to the tableview.
    What do you mean with "don't positon/size them manually"?
    Sorry for the many questions.


  • Lifetime Qt Champion

    @Mogli123
    Hi
    first of all. Questions are super ok here.
    Just make sure to try to make it as clear as possible
    what the goal is.

    So can we talk about
    why you need to be able to alter the position of the tables in the first place?
    and also is that the UI xml file or your own format/file?



  • Thats my own xml.
    I have the basic format from the UI xml file.
    I need the tableviews for displaying data from a machine for the user.
    The user should have the possibility to change the position and the size of the tables without changing something in Qt.


  • Lifetime Qt Champion

    @Mogli123
    ok, the normal use of layout to make table follow window size cannot be used?
    you need multiple tables on the form in floating positions user select?

    The user must freely position the table on the form/window?

    Im asking as free placement is somewhat unusual. normally
    we use QSplitter and layouts to allow the user to size a section/area and
    sometimes QDockWidgets to have windows you can move around.



  • @mrjj
    The tables look like this example.
    I have creat the tables with the designer and with layouts so far.
    The user shoud have the possibility to change the size and position but not with the designer.
    Why he should have that possibility I don't know. That was not my idea ;) .
    I'm trying it with xml because thats the only way I know to have the possibility to solve the problem.
    But I don't know how exactly.

    0_1539334379045_example.PNG


  • Lifetime Qt Champion

    @Mogli123 said in manipulate the position of a tableview with an xml file:

    don't positon/size them manually

    That's not what I wrote, please reread



  • @jsulm

    oh sorry for that


Log in to reply