Results 1 to 4 of 4

Thread: QDialog - no title bar

  1. #1
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QDialog - no title bar

    Hello!

    I've wrote simple program that have main window and dialog window which can by open by clicking a button. Code of that dialog window looks like this:

    Qt Code:
    1. #include <QGridLayout>
    2. #include <QPushButton>
    3. #include <QIcon>
    4.  
    5. #include "pomiary.h"
    6.  
    7. Pomiary::Pomiary(QWidget *parent)
    8. : QDialog(parent)
    9. {
    10. setupUI();
    11. }
    12.  
    13. void Pomiary::setupUI()
    14. {
    15. setModal(true);
    16. setGeometry(QRect(50,0,100,150));
    17. setWindowIcon(QIcon(":/images/icon.png"));
    18.  
    19. QGridLayout* PomiaryLayout = new QGridLayout;
    20. setLayout(PomiaryLayout);
    21.  
    22. QPushButton *button = new QPushButton();
    23. button->setIcon(QIcon(":/images/icon2.png"));
    24. button->setIconSize(QSize(48, 48));
    25. button->setFixedSize(60, 60);
    26. PomiaryLayout->addWidget(button,0,0,Qt::AlignHCenter);
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 

    and when I open my application i don't have title bar on dialog window so I can't close it. I've tried to use setWindowFlags() but with no result. Only If I delete 'setGeometry()' window has title bar but is very small, and I want specific size. What I'm doing wrong?

    thanks in advance
    best regards
    Tomasz
    Last edited by Tomasz; 22nd July 2010 at 10:25.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog - no title bar

    What if you change "0" in your setGeometry call to say... 40?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Tomasz (22nd July 2010)

  4. #3
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDialog - no title bar

    I've used setFixedSize(); and it worked perfectly.

    best regards
    Tomasz

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog - no title bar

    In general I think youi are missing a point of how Qt does its job. Setting fixed size on a dialog is a bad idea and having to do that often means you did something very wrong (like not using layouts).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Show maximize button in the title bar of a QDialog under GNOME
    By lalesculiviu in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2010, 07:46
  2. stylesheet to QDialog Title Bar
    By srinirc in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 15:32
  3. closing a Qdialog called from a Qdialog
    By OverTheOCean in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2009, 08:02
  4. Replies: 5
    Last Post: 21st April 2008, 07:54
  5. window title bar
    By moowy in forum Qt Programming
    Replies: 4
    Last Post: 21st September 2006, 16:56

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.