Results 1 to 9 of 9

Thread: load a Window

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default load a Window

    Hi,
    I have a program in QT. In that program I create a tree using QTreeView. When I double click on an item in the tree, at that time I need to create a Window. I do that, and it is working. My probs is that, When I double click on an item, then it create a new window and again i double click on the same item, I need to show the old window. But in my program, it create a new window. For each time the name of the window is change ( the text of the item) How can I check the name ( the window withe a name ) is loaded?
    Please help me..........

  2. #2
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: load a Window

    Quote Originally Posted by sabeesh View Post
    Hi,
    I have a program in QT. In that program I create a tree using QTreeView. When I double click on an item in the tree, at that time I need to create a Window. I do that, and it is working. My probs is that, When I double click on an item, then it create a new window and again i double click on the same item, I need to show the old window.
    Well, this doesn't have much to do with Qt. You just have to map tree-items to window-pointers in your program (initiate all the pointers to NULL). When someone double-clicks on an item, you check if the associated window-pointer is NULL (meaning: a window has not yet been created). If so, create the window. Then show the window either way.

    At least, that's how I'd do it.

    Quote Originally Posted by sabeesh View Post
    But in my program, it create a new window. For each time the name of the window is change ( the text of the item) How can I check the name ( the window withe a name ) is loaded?
    I don't really understand what you mean here. Try my suggestion. If it doesn't help, please explain more clearly what you want your program to do.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  3. #3
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: load a Window

    Hi,
    I have tree in my program. The nodes in the trees are 'Camera 1', 'Camera 2', 'Camera 3', etc. When I double click on the node 'Camera 1' then a window is created named as 'Camera_1', when I double click on nod 'Camera 2' then a nother window is load named as 'Camera_2' like that.....
    My problem is that, When I double click on a node, 'Camera 1' at first time, then a new window is created and load name of that window is 'Camera_1' and when I double click again on that node then, another window is created named as 'Camere_1'. I want to block this. If one window is loaded, then when i double click on the same node, I need to show the old window no need to create a new one, if it is created early. ( check the name in memory)....
    Please help me

  4. #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: load a Window


  5. #5
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: load a Window

    Quote Originally Posted by sabeesh View Post
    Hi,
    I have tree in my program. The nodes in the trees are 'Camera 1', 'Camera 2', 'Camera 3', etc. When I double click on the node 'Camera 1' then a window is created named as 'Camera_1', when I double click on nod 'Camera 2' then a nother window is load named as 'Camera_2' like that.....
    My problem is that, When I double click on a node, 'Camera 1' at first time, then a new window is created and load name of that window is 'Camera_1' and when I double click again on that node then, another window is created named as 'Camere_1'. I want to block this. If one window is loaded, then when i double click on the same node, I need to show the old window no need to create a new one, if it is created early. ( check the name in memory)....
    Please help me
    Looks like you just repeated your question again. Seems like my suggestion would work. Is there something specific about it you don't understand?
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  6. #6
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: load a Window

    Hi,
    Can you explain how can i check, if the associated window-pointer is NULL?

  7. #7
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: load a Window

    Qt Code:
    1. if (pointer == NULL) {
    2. ...
    3. }
    To copy to clipboard, switch view to plain text mode 
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  8. #8
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: load a Window

    Hi,
    This is my function, When I double click on a node at that time this function is work,

    void CreateCamWindow( QString Name, QString Title ){

    CamPanel *Panel = new CamPanel;
    Panel->setObjectName(Name);
    Panel->setGeometry(QRect(161, 14, 250, 200));
    Panel->setWindowTitle(Title);
    Panel->show();
    }

    Here How can I check it? In the variable Name the value come as 'Camera_1'. Then, how can I check the window is loaded?

  9. #9
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: load a Window

    Ok, so you say the names are unique. You could do it this way:

    Qt Code:
    1. void CreateCamWindow( QString Name, QString Title ) {
    2. static QMap<QString, CamPanel*> panels;
    3.  
    4. if (!panels.contains(Name)) {
    5. panels.insert(Name, new CamPanel);
    6. }
    7. panels[Name]->setObjectName(Name);
    8. panels[Name]->setGeometry(QRect(161, 14, 250, 200));
    9. panels[Name]->setWindowTitle(Title);
    10. panels[Name]->show();
    11. }
    To copy to clipboard, switch view to plain text mode 

    But that's only because I have only seen that one function. There are more elegant ways to do the same.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

Similar Threads

  1. Replies: 4
    Last Post: 4th June 2007, 12:07
  2. Regarding drawing on Transparent Window
    By Shalabh in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2007, 10:32
  3. Independant window in an application
    By titoo in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 11:07
  4. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

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.