Results 1 to 7 of 7

Thread: How to make frameless widget as a window or dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default How to make frameless widget as a window or dialog

    I made a frameless widget which has its own titlebar. When this widget has a parent widget, it doesn't act as a separate window anymore, but I want to have it popup as a dialog. Unfortunately I can't minimize, maximize it. It stays inside the parent widget frame. How can I make this frameless widget still act as an independent window or dialog when it has a parent widget?

    The code looks something like this:

    #include <QtGui>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QMainWindow mainWin;
    mainWin.show();

    FramelessWidget myWid(&mainWin, Qt:ialog | Qt::FramelessWindowHint);
    myWid.show();

    return app.exec();
    }

    Anyone has any ideas?
    Last edited by ainne810329; 3rd November 2011 at 12:32.

  2. #2
    Join Date
    Oct 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: How to make frameless widget as a window or dialog

    Hi

    ok first of all, what kind of widget is your FramelessWidget? QWidget? QDialog? QObject?
    when its from QDialog, then u dont need to set a parent in your constructor:
    Qt Code:
    1. main.cpp:
    2. ...
    3. FramelessWidget myWid(Qt::Dialog | Qt::FramelessWindowHint);
    4. myWid.show();
    To copy to clipboard, switch view to plain text mode 
    but then u have to change your constructor in your framelesswidget.cpp to:
    Qt Code:
    1. FramelessWidget(..., QWidget* parent = 0);
    To copy to clipboard, switch view to plain text mode 
    because arguments with default-values must be at last positions in the constructor.

    if your FramelessWidget is inhertide from QWidegt, then u need a QDialog or QMainWindow like:

    Qt Code:
    1. main.cpp:
    2. {
    3. ...
    4. QMainWindow mainWin;
    5. mainWin.show();
    6.  
    7. QDialog dia;
    8. FramelessWidget(&dia, Qt::Dialog | Qt::FramelessWindowHint);
    9. dia.show();
    10.  
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    this code snippet creates one MainWindow and one Dialog-Window.

    i hope i could help you

    with best regards

    nudels

  3. #3

    Default Re: How to make frameless widget as a window or dialog

    First, thank you very much for your respond.

    The FramelessWidget is derived from QWidget indeed, by using a QDialog as a parent of my frameless widget, the purpose to have custome title bar and borderless dialog can not be achieved anymore.

    Secondary, I do want this frameless widget to be a child dialog of the mainwindow, so it stays on top of the mainwindow and when the mainwindow is minimized, the frameless dialog is also minimized.

    Any idea how I can achieve my goals?

  4. #4
    Join Date
    Oct 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: How to make frameless widget as a window or dialog

    can u plz post the framelesswidget constructor?

    u want to have one Window, that is the parent of ur framelesswidget? is that right?

    best regards

    nudels

Similar Threads

  1. Move Frameless Dialog
    By deepal_de in forum Qt Programming
    Replies: 7
    Last Post: 6th June 2011, 09:35
  2. Frameless Window Helper
    By nish in forum Qt-based Software
    Replies: 6
    Last Post: 20th February 2011, 08:28
  3. Replies: 10
    Last Post: 26th October 2010, 00:59
  4. Resize handling of frameless window
    By Peppy in forum Qt Programming
    Replies: 5
    Last Post: 2nd June 2010, 21:48
  5. How to show a frameless dialog - DOESN'T WORK
    By franco.amato in forum Newbie
    Replies: 4
    Last Post: 2nd June 2010, 18:21

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.