Results 1 to 11 of 11

Thread: Is overlapping layer possible in qt layouts?

  1. #1
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Is overlapping layer possible in qt layouts?

    I have game , I use layout for diffent screen resolution device. so far so good. but If use a layout , not use overlapping widget
    for example my game screen shoot this , and all widget place from layout.
    superslot_R5jjKD95cG.jpg

    if I wantto show money flush animation movie .gif full screen (over game screen, trasnparent widget) I have to add new hidden wigdet in centralwidget. but this widget join in layout and goto screen right side and corrupt its size.
    I want it to look like the picture below (if I remove all layouts and set my game single screen resolition this work)

    Y5yRmcW8Qb.jpg

    xx117f6tao.jpg

    how to do that in layouts.

    In summary, I want a widget independent of "layout". absolute position widget in layout.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is overlapping layer possible in qt layouts?

    Maybe you can use a QDialog with no frame and a transparent background instead of a widget? If this animation widget is not displayed all the time, but only when the player gets a bonus or some other special event occurs, then you could use a QDialog that contains a QTimer with a timeout() signal connected to the QDialog's close() slot. In the dialog's showEvent(), start the timer. When the timer times out, the dialog will be closed. If you make the main window the dialog's parent, it will be centered in the main window but will not change the layout because it is independent of the layout. You can make the dialog any size you want, so it could cover the entire main window or just part of it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is overlapping layer possible in qt layouts?

    First of All. Thank for reply and time d_stranz

    I was using QDialog before, but modal QDialog has lots of troubles (eg serialport not work ,defined in mainwindow etc). so it was great for me to use widgets as a QDialog, since I designed 800x600 fixed resolution. but I had to turn the same software into a tablet. When the android tablet resolution was 1280x800, I rearranged the design and added layouts. however, this time dialog widgets became a problem. this is the story of the question.

    Qt developers can actually develop widgets that don't depend on layouts. this may be optional. it would be very useful, if not too difficult.
    Last edited by sevketk; 21st July 2020 at 10:07.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is overlapping layer possible in qt layouts?

    Your QDialog does not have to be modal (which causes other parts of the UI to freeze). If you call QDialog::exec(), then the dialog will be modal. If you create it with a non-modal property (QDialog::setModal() with false), then you can call QDialog::show() and QDialog::hide() and the rest of your UI keeps working.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is overlapping layer possible in qt layouts?

    is QDialog responsive?

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is overlapping layer possible in qt layouts?

    is QDialog responsive?
    I am not sure what you mean. If you post the QDialog as non-modal, using show(), then yes, it will be responsive, but so will the rest of your UI.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #7
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is overlapping layer possible in qt layouts?

    Quote Originally Posted by d_stranz View Post
    I am not sure what you mean. If you post the QDialog as non-modal, using show(), then yes, it will be responsive, but so will the rest of your UI.
    responsive = It means auto resize , it means , it works on diffent screen resolution devices, proportional size . has it top-level layout?
    Last edited by sevketk; 26th July 2020 at 20:18.

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is overlapping layer possible in qt layouts?

    The behavior is no different from any other dialog. So if you do not set parameters that would keep it from expanding, then it should resize for different screens.

    Why don't you just try it instead of asking questions?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  9. #9
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is overlapping layer possible in qt layouts?

    Ok. I tried. I create with qt creator ui designer new Qdialog
    qtcreator_dVdKqYG5i2.jpg

    and add one button (preffered size policy) , add layout horizantal and I called it

    void MainWindow:n_pushButton_clicked()
    {
    Dialog myDialog;
    myDialog.setModal(false);
    myDialog.exec();
    }
    when I run it , mainwindow occupied the entire screen, but qdialog remained to the extent given. this is result

    qemu-system-i386_DfYqbm8sK8.jpg

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is overlapping layer possible in qt layouts?

    Why don't you explain exactly what it is you want this dialog to do?

    You have set the dialog size to 400 x 300 in Qt Designer, so that is what you see when you call exec(). You did not construct myDialog with the MainWindow instance (this) as the parent, so the dialog is centered on the screen, exactly as it is supposed to be when it it created as a top-level widget (ie. with no parent).

    And despite your code calling setModal( false ), when you call exec() it cancels this and displays the dialog as modal. If you want a non-modal dialog, you must use show() and hide().
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  11. The following user says thank you to d_stranz for this useful post:

    sevketk (30th July 2020)

  12. #11
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is overlapping layer possible in qt layouts?

    this seems to be the solution for me.

    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    myDialog = new Dialog(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow:n_pushButton_clicked()
    {

    //myDialog.setModal(false);
    myDialog->showMaximized();
    myDialog->raise();

    }

Similar Threads

  1. qtmobility map adding layer
    By stevocz in forum Newbie
    Replies: 0
    Last Post: 16th June 2014, 09:24
  2. Adding a layer to QwtPlotSpectrogram
    By DizzyMoods in forum Qwt
    Replies: 1
    Last Post: 27th August 2012, 09:28
  3. multi layer application
    By gpuntoni in forum Newbie
    Replies: 2
    Last Post: 11th January 2010, 18:30
  4. UDP IP layer limit
    By mhoover in forum General Programming
    Replies: 1
    Last Post: 1st August 2009, 17:13
  5. Controlling which widget on top layer?
    By JonathanForQT4 in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2007, 15:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.