Important: Please read the 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"?>
    	<widget class="QMainWindow" name"test_screen">
    		<widget class="QWidget" name="centralWidget">
    			<widget class="QLabel" name="label_2">
    				<property name="geometry">

    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:

  • 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

    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

    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.


  • 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