Results 1 to 7 of 7

Thread: How to deactivate close button in lubuntu?

  1. #1
    Join Date
    Aug 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to deactivate close button in lubuntu?

    Hi,
    I create my program in qt (c++) with ubuntu OS. I have to move my application to a lubuntu os on another pc. I know how to make a make-file and move the program.
    My problem is: I want to disable the close-button in a QTabWidget.

    I did it with:

    Qt Code:
    1. QTabWidget tabWidget = new QTabWidget;
    2. tabWidget->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    To copy to clipboard, switch view to plain text mode 

    When I use this in Ubuntu, everything works like I want (not able to push close-button). But when I move the programs make-file to lubuntu-PC, the close-button appears again. When I push x (close-button) in lubuntu the program stops.

    I need to deactivate this button.
    Does anybody know how to do that?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to deactivate close button in lubuntu?

    You don't seem to have disabled the close buttons on tabs at all: QTabWidget::setTabsClosable()

    Edit:
    Oh, I see, this has nothing to do with tab widgets. You want to remove the OS close button on a top level window. You tried turning off the default window flags with Qt::CustomizeWindowHint... but the window manager is under no obligation to honour these flags, and it varies from OS to OS also. Removing this button will not stop the user from closing the program with Alt+F4 (for example) anyway. Why do you want to remove the close button?
    Last edited by ChrisW67; 23rd September 2011 at 01:50.

  3. #3
    Join Date
    Aug 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to deactivate close button in lubuntu?

    Thanks for your reply

    I'm making an alarm system. I want to let the program that handle the alarms be uncloseable. In addition I want to let the screen show the active alarms all the time.

    Are you able to help me?

  4. #4
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Thanks
    1
    Thanked 11 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to deactivate close button in lubuntu?

    How about to ignore closeEvent ?
    And if you really want to close your app by pressing a button, or something else, set "ignore event" variable to false.

  5. #5
    Join Date
    Aug 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to deactivate close button in lubuntu?

    Thanks for the tips.

    I have tried this several times, but the still not work in my program. I'm wondereing about how to implement it.

    My main call a StartProgram(QWidget). No GUI started.

    StartProgram call a TabDialog(QTabDialog). This tabdialog starts a tabWidget(QTabWidget) in this way:
    Qt Code:
    1. QTabWidget tabWidget = new QTabWidget;
    2. StartPageTab startpagetab = new StartPageTab();
    3. FindPageTab findpagetab = new FindPageTab();
    4. tabWidget->addTab(startpagetab, tr("StartPage");
    5. tabWidget->findpagetab, tr("FindPage");
    6. tabWidget->show();
    To copy to clipboard, switch view to plain text mode 

    In which class should I implement the closeEvent?
    I have tried in the TabDialog, and in the findpagetab and startpagetab.
    Can you please help me?

  6. #6
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Thanks
    1
    Thanked 11 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to deactivate close button in lubuntu?

    I don't get it exactly.
    If this is the entire code (i.e. QTabWidget is top level widget of your application), then you need to subclass QTabWidget, and implement closeEvent in the new class.
    If QTabDialog is top level window, and I assume you subclass QTabDialog from QDialog, and not using Qt3, then closeEvent must be implemented in your QTabDialog subclass.

  7. #7
    Join Date
    Aug 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to deactivate close button in lubuntu?

    Thank you.

    I had used some Dialogs and some Widgets. Now all are widgets, and the close button(x) is disanbled by closeEvents and a bool ignoreCloseEvent.


Similar Threads

  1. Replies: 2
    Last Post: 6th May 2011, 08:02
  2. Replies: 2
    Last Post: 26th April 2011, 11:44
  3. Close Button
    By Lycus HackerEmo in forum Newbie
    Replies: 4
    Last Post: 30th December 2009, 05:27
  4. Close button in a tab
    By mitro in forum Newbie
    Replies: 2
    Last Post: 16th May 2008, 10:22
  5. How to deactivate the marking in a QTable?
    By mantra in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2008, 15:51

Tags for this Thread

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.