PDA

View Full Version : How to deactivate close button in lubuntu?



inger
22nd September 2011, 10:24
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:


QTabWidget tabWidget = new QTabWidget;
tabWidget->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);

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?

ChrisW67
23rd September 2011, 01:37
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?

inger
23rd September 2011, 07:23
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?

cincirin
23rd September 2011, 14:10
How about to ignore closeEvent (http://doc.qt.nokia.com/latest/qwidget.html#closeEvent) ?
And if you really want to close your app by pressing a button, or something else, set "ignore event" variable to false.

inger
6th October 2011, 13:13
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:

QTabWidget tabWidget = new QTabWidget;
StartPageTab startpagetab = new StartPageTab();
FindPageTab findpagetab = new FindPageTab();
tabWidget->addTab(startpagetab, tr("StartPage");
tabWidget->findpagetab, tr("FindPage");
tabWidget->show();

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?

cincirin
6th October 2011, 13:32
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.

inger
10th October 2011, 11:34
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.

:)