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

Positioning new on complete application



  • Hello, everyone,
    I have complete application, all widgets on it are positioned with layouts, everything is working fine, but I have to add new widget: popup notification (something like windows 10 notification that pops in the right corner of the screen, but I don't want to use windows toasts, because these notifications have to be binded right to this app). So the problem is to position this widget: I can place it in right position on empty form by adding it to QGridLayout to cell (1;1) and two spacesrs to cells (0;1) and (1;0), but the problem is I can't add that layout to existing form with QVBoxLayout on CentralWidget.
    So is there a way to have two equal layouts binded to the same Widget? Actually I can position this new popup widget manually, but in that case I have to add special logic for form resizing, and it seems like this is not the best solution.



  • @Beatler said in Positioning new on complete application:

    but the problem is I can't add that layout to existing form with QVBoxLayout on CentralWidget.

    I dont see any reason why you cant do that :)
    You can have multiple (sub-)layouts in one main layout.

    Using cascading VBox and HBox layouts is often the better choice anyway.



  • I need to avoid changing the existing layout. So I have centralWidget, Vertical Layout on it (lets call it MainLayout) and many sublayouts, but I need to add one more layout to centralWidget, not sub layout for MainLayout.



  • @Beatler said in Positioning new on complete application:

    I need to add one more layout to centralWidget

    That's not possible. A widget can only have one base layout at a time.

    Why not use a HBox layout, move all your current stuff (the VBox layout) to the left and use the right for your popup widget?
    (Use can set a stretch to get 90%/10% of your available space, for example.)



  • @Pl45m4
    "That's not possible. A widget can only have one base layout at a time."
    This is what I want to know, I will look for another solution, probably I will use absolute positioning inside centralWidget.

    "Why not use a HBox layout, move all your current stuff (the VBox layout) to the left and use the right for your popup widget?"
    Cuse I can't change overall positioning in this app. My popup notification must pop above all contents and not to affect existing content. So this widget is not visible most of the time, under some circumstances it becomes wisible, and after few seconds it will disappeare.