Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDialog position flickers with move command
QtWS: Super Early Bird Tickets Available!

QDialog position flickers with move command

Scheduled Pinned Locked Moved Unsolved General and Desktop
qdialogmodal dialogmove problem
10 Posts 3 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #1

    I create a custom QDialogBox class and try to display it in the centre of my window using the 'move' command. The dialog box appears at a random position on the screen and then moves to the position set by me after 1 second. This happens at random instances on mac machine. Is this a Qt problem with mac? is there a workaround?

     CustomDialog *loginDialog = new CustomDialog( this );//a QDialogBox class
            float width=350,height=180;
            dialogBoxPosition(&width, &height);
            _mFinalPoint.setX(width);
            _mFinalPoint.setY(height);
            loginDialog->move(_mFinalPoint);//moving it to a window center
            loginDialog->loginWindow();//calling a member function        
            loginDialog->exec();
    
    1 Reply Last reply
    0
  • jsulmJ Offline
    jsulmJ Offline
    jsulm Lifetime Qt Champion
    wrote on last edited by
    #2

    May I ask you why you use float for width and height?
    What is dialogBoxPosition() doing?
    What is loginDialog->loginWindow() doing?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #3

    Thank you for the reply.

    1. I just used float. Should I use any other type.
    2. Dialog box position calculates values for width and height
    3. loginwindow is a member function which displays some buttons inside the QDialog box.
    1 Reply Last reply
    0
  • jsulmJ Offline
    jsulmJ Offline
    jsulm Lifetime Qt Champion
    wrote on last edited by
    #4

    Using float does not make sense because width and hight in a QWidget are integer types, so you have useless type conversions.
    Could it be a move-animation on OS X which takes time?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #5

    I changed all the floats to int but the problem still persists. The move command moves the box to the required position but the default position of the box is something else. How can I set this default position? I also tried using setGeometry but the same problem exists.

    1 Reply Last reply
    0
  • SGaistS Offline
    SGaistS Offline
    SGaist Lifetime Qt Champion
    wrote on last edited by
    #6

    Hi,

    Something along these lines should work and be simpler:

    QRect dialogGeometry = loginDialog->geometry();
    dialogGeometry.moveCenter(geometry().center());
    loginDialog->setGeometry(dialogGeometry);
    loginDialog->exec();
    

    Note that your loginDialog construction is a bit unusual, why not build all the UI inside its constructor ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #7

    Hi, I tried using this code and I also tried to set geometry inside the constructor but I am facing the same problem. The dialog box appears for a fraction of section in one location and then it moves to the location set by me.

    Another thing, I was able to solve this problem in Qt Creator. However, when I try to run the same code in Xcode(mac machine), I see this flickering. Could it be a qt mac problem?

    1 Reply Last reply
    0
  • SGaistS Offline
    SGaistS Offline
    SGaist Lifetime Qt Champion
    wrote on last edited by
    #8

    What version of Qt and OS X are you running ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
  • S Offline
    S Offline
    sunil.nair
    wrote on last edited by
    #9

    qt version 5.5.
    OS X 10.10
    Xcode version 6

    1 Reply Last reply
    0
  • SGaistS Offline
    SGaistS Offline
    SGaist Lifetime Qt Champion
    wrote on last edited by
    #10

    Can you share a sample code that reproduce that ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved