Results 1 to 3 of 3

Thread: Issue when i open window from mainwindow after the 1st time - it will open very small

  1. #1
    Join Date
    Mar 2018
    Posts
    34
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Windows

    Default Issue when i open window from mainwindow after the 1st time - it will open very small

    In my code code attached i have this issues:
    1 - when i open the edit window at 1st time the window will be open right, next time it will open very small?
    (if i make some mistake in my code tell me what is the right procedure to do the job by explain me with some code, thank you)
    2 - I'm trying to reduce the "color-label" to the width of the combobox, i have tried some but with no effect, how i can do it?
    3 - when i try to close the main window by pressing with the mouse on X button, no happen?

    IN "application output" of Qt compiler is showed this message after the 1st open:
    QWidget::setLayout: Attempting to set QLayout "" on EditObject "", which already has a layout

    after i used an auxiliary update_val:
    Qt Code:
    1. void EditObject::window_elements_update()
    2. {
    3. ....
    4. if (update_val){
    5. update_val = 0;
    6. setLayout(final_layout);
    7.  
    8. }
    9. else {
    10. layout()->update();
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    and the message "QWidget::setLayout: Attempting to set QLayout "" on EditObject "", which already has a layout" disappeared but the window still small after the 1st open window
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Issue when i open window from mainwindow after the 1st time - it will open very s

    Every time you call EditObject:: window_elements_update() you are creating all of your EditObject's UI without removing the UI that was created in the last call. Extra checkboxes (without deleting the old ones - clear() does not do anything except erase the pointers. It does not delete the checkbox instances). You load all the same images over again even though you loaded them the last time through the function. You create a new list to hold the images without deleting the old one (another memory leak). This code is such a mess of mistakes it needs to be thrown out and completely rewritten.

    I think you need to stop spewing out broken code, sit down, and write in words, not code what you want your application to do, and what should happen at each step in the process. Then, think about the data structures you need for the information your app handles, and the UI you need to display and interact with it.

    If you don't do this, then every day you will run into another problem, your code will get buggier and buggier, and you will waste a huge amount of time trying random things to fix it because you haven't taken the time to do a proper design or to understand how to use Qt properly.
    Last edited by d_stranz; 6th October 2020 at 01:39.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    andreaQt (27th October 2020)

  4. #3
    Join Date
    Mar 2018
    Posts
    34
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Issue when i open window from mainwindow after the 1st time - it will open very s

    Now this program do what i want, open an edit window, populate it like i want and i can update the mainwindow from the edit window.
    I have some question:
    1 - why when i try to do this setFixedSize( .... ) on a window (mainwindow or editwindow), the window that refer this setup have an issue: i can't close it by click with the mouse on X red button?
    i avoid this issue by resize( .... ) + setMinimumSize( .... ) + setMaximumSize( ... ) ; i'm working on -> Qt Creator 4.11.0 Based on Qt 5.14.0
    2 - i'm a beginner on Qt, an in progamming, is it the right way to structure the job?
    Attached Files Attached Files

Similar Threads

  1. Replies: 0
    Last Post: 5th October 2020, 13:29
  2. Replies: 4
    Last Post: 24th December 2016, 14:22
  3. Replies: 0
    Last Post: 9th May 2010, 21:49
  4. Open Dialog from MainWindow.
    By halvors in forum Qt Programming
    Replies: 8
    Last Post: 1st April 2010, 02:09
  5. Open mainwindow
    By cwnelatury in forum Newbie
    Replies: 1
    Last Post: 17th April 2009, 23:46

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.