LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-20-2012, 07:12 PM   #1
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Rep: Reputation: 2
How to close the main window in Qt creator without exiting the program?


I have been googling this for the past week, and I can't find how to close the main window in Qt creator without closing the program. I tried to go as far as I could without asking for help, but this one just go me.

EDIT:
What I want to do is, create a main window that has options that opens up other windows, then close that main window without exiting the program.

Last edited by darkstarbyte; 07-22-2012 at 04:22 PM. Reason: simplify
 
Old 07-22-2012, 10:45 PM   #2
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
I guess not very many people use Qt creator to code GUIs.
 
Old 07-24-2012, 01:10 PM   #3
saman_artorious
Member
 
Registered: Sep 2008
Posts: 78

Rep: Reputation: 1
Quote:
Originally Posted by darkstarbyte View Post
I guess not very many people use Qt creator to code GUIs.
try hiding the mainwindow. You somehow cannot close it as it is the application only active window in the main program.
so, once it is returned, the main program returns.
 
Old 07-29-2012, 03:44 AM   #4
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
Oh, with the hide function. (If I am naming the right one.)

Thanks for your response, I was starting to think I was a very lonely coder.
 
Old 07-31-2012, 03:32 PM   #5
saman_artorious
Member
 
Registered: Sep 2008
Posts: 78

Rep: Reputation: 1
Quote:
Originally Posted by darkstarbyte View Post
Oh, with the hide function. (If I am naming the right one.)

Thanks for your response, I was starting to think I was a very lonely coder.
!!! why lonely! it seems you are not familiar with the qt center forum: http://www.qtcentre.org
 
Old 08-02-2012, 11:36 AM   #6
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
thanks, it denied me a couple of times through the image verification. Those are getting harder to pass than learning to write programs.
 
Old 08-04-2012, 03:22 AM   #7
saman_artorious
Member
 
Registered: Sep 2008
Posts: 78

Rep: Reputation: 1
Quote:
Originally Posted by darkstarbyte View Post
Oh, with the hide function. (If I am naming the right one.)

Thanks for your response, I was starting to think I was a very lonely coder.
I got what you were looking for. I have two main windows in my program. you may have created a variable of the second window in the first windows header file and initiated it in the first windows constructor. So, set its parent to 0. if you do this, you can close the first window then.

here's a sample:

first window header
Code:
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    SettingsWindow *settings;
first window constructor:
Code:
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    settings = new SettingsWindow(cfg,0);
second (settings) window constructor:
Code:
SettingsWindow::SettingsWindow(ConfigSource &src, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::SettingsWindow)
{
you may not worry about the first parameter of settings window, COnfigSource, I mean, I have added this myself. you simply have one parameter which is QWidget *parent. set it to 0.

(problem solved )
 
1 members found this post helpful.
Old 08-09-2012, 02:46 AM   #8
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
I will leave this unsolved, just in case more problems arise about this subject.

EDIT:
Thanks for your response saman_artorious
 
  


Reply

Tags
c++, qt, window


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exiting window managers crashes video ADX Linux - Newbie 1 08-18-2011 03:18 AM
my first activity runing happen error:Uncaught handler: thread main exiting due to un firmlyjin Linux - Mobile 1 09-03-2010 04:43 PM
Javascript - what to use rather than window.close() then window.open() davee Programming 2 04-11-2005 08:28 AM
Why do i get segmentation fault upon exiting main() J-Ral Programming 5 05-28-2004 04:27 AM
exiting x window mode Galilee Linux - Software 4 10-01-2003 12:21 AM


All times are GMT -5. The time now is 01:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration