View Full Version : close() and show()->newwindow problem
danoc93
24th January 2012, 16:55
I'm using this on my program to call new windows, but there is a problem... I close the actual window and call a new one. It works, but the icon on the task bar vanishes so my application is "floating" on the desktop :(, what could be happening?
wysota
24th January 2012, 19:56
Please describe your problem better. Possibly with a piece of code or a screenshot.
danoc93
25th January 2012, 01:06
MM ok...
I have 2 classes...
Window1.h
Window1.cpp
Window2.h
Window2.cpp
The program starts and Window1 shows up just fine...
Then using this code
in Window1.h
#include Window2.h
public slots:
void openwindow2();
private:
Window2 * window2win;
private slots:
void on_button_clicked();
in Window1.cpp
void Window1::on_button_clicked(){
openwindow2();
}
void Window1::openwindow2(){
close(); //closes current window
window2win = new Window2 (this);
window2->show(); //shows the new window but it doesn't appear on task bar...
}
Look:
I click on "codigos de ejemplo" and the new window shows up but the icon dissapears once the previous window closes... lol...
http://farm8.staticflickr.com/7145/6757768857_80f8250035_z.jpg
http://farm8.staticflickr.com/7019/6757770923_ce714aaae2_z.jpg
ChrisW67
25th January 2012, 05:50
Only parent-less QWidgets become windows, and only top-level windows get a task bar presence. Make window2 parent-less and then worry about memory deallocation (Qt::WA_DeleteOnClose).
Lykurg
25th January 2012, 06:43
And have you thought about using QStackedWidget? Thus you don't have to close() and hide() your windows and can stay with one main window.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.