Results 1 to 11 of 11

Thread: Is overlapping layer possible in qt layouts?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,327
    Thanks
    317
    Thanked 871 Times in 858 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.

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

    sevketk (30th July 2020)

  4. #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?

    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, 08:24
  2. Adding a layer to QwtPlotSpectrogram
    By DizzyMoods in forum Qwt
    Replies: 1
    Last Post: 27th August 2012, 08:28
  3. multi layer application
    By gpuntoni in forum Newbie
    Replies: 2
    Last Post: 11th January 2010, 17:30
  4. UDP IP layer limit
    By mhoover in forum General Programming
    Replies: 1
    Last Post: 1st August 2009, 16:13
  5. Controlling which widget on top layer?
    By JonathanForQT4 in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2007, 14: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
  •  
Qt is a trademark of The Qt Company.