How to confirm the Widget Order in Qt Creator? - qt

I've just defined the order in which I want my widgets on a Qt GUI but I can't confirm my action after hours of researches. How can I do it please ?
Here is the order I defined :
I would like the widgets to be in this order : 1 - 2 - 3
But here, there are in that order : 3 - 2 - 1
I tried to build the project to see if something different happens but it just builds exactly what I see on Qt Creator :
I read the tutorial below but there's no information about my problem : https://doc.qt.io/archives/4.3/designer-tab-order.html#:~:text=Setting%20the%20Tab%20Order,position%20in%20the%20tab%20order.
Btw, I don't understand why it's that complicated to do such a simple thing. It's crazy that just pressing the Enter key doesn't do the trick.

I found what I needed. To re-order widgets, we just have to move them manually with the mouse.

Related

Xcode AppDelegate wont link to textfields

I am following along in a book to learn swift and I am building a basic loan calculator for OS-X using XCode. I am getting two errors in my code and it wont allow me to attach the Outlets to my textfields. The errors are:
Line 16 - Use of Undeclared type "NSTestField" but I changed it to NSTextField and it still shows an error under the mistyped var name.
Line 35 - Postfix "." is reserved. The error carrot is on the dot between loanAmountField and doubleValue.
Also, it wont allow me to drag the outlets into my app. I am guessing I did not attach the appdelegate file to the right window since the window option is not marked but I cant figure out how to do that. The book just says it should already be marked.
My code showing errors
(Sorry, I tried using the "code sample" button when posting this but even after indenting 4 spaces and pasting my code it continued to tell me I did not indent.)
The appdelegate showing that "window" isnt marked

Xcode 4.4 constraint errors

I am using Xcode 4.4 and creating my views in interface builder. When I run my app, I consistently get the following constraint errors.
Unable to simultaneously satisfy constraints:
(
"<NSAutoresizingMaskLayoutConstraint:0x104486db0 h=-&- v=-&- V:[NSView:0x106a33090]-(0)-| (Names: '|':NSClipView:0x106a0cef0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x104486e10 h=-&- v=-&- V:|-(15)-[NSView:0x106a33090] (Names: '|':NSClipView:0x106a0cef0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1002da350 h=--& v=--& V:[NSClipView:0x106a0cef0(672)]>",
"<NSLayoutConstraint:0x106a11ba0 V:[NSView:0x1044eb990]-(657)-| (Names: '|':NSView:0x106a33090 )>",
"<NSLayoutConstraint:0x1044d68d0 V:|-(270)-[NSView:0x1044eb990] (Names: '|':NSView:0x106a33090 )>",
"<NSLayoutConstraint:0x100271040 V:[NSView:0x1044eb990(245)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x100271040 V:[NSView:0x1044eb990(245)]>
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints
to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.
And/or, break on objc_exception_throw to catch this in the debugger.
Any suggestions on how I can resolve this?
Thanks
For each view you're intending on constraining do this:
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
That will get rid of the "NSAutoresizingMaskLayoutConstraint" parts in the log.
There is also a way to solve this without writing code.
In the storyboard, select your super view. In the Attributes Inspector, deselect the "Autoresize Subviews" checkbox as shown below.
This will add autoresizesSubviews="NO" to the storyboard XML file. In my case, the XML already contained translatesAutoresizingMaskIntoConstraints="NO", however, this did not stop autolayout from creating NSAutoresizingMaskLayoutConstraints.
Note: Maybe my answer applies to Xcode 5 only, as I can't check if Xcode 4.4 already had this checkbox. But since Google still turns up this SO question when searching NSAutoresizingMaskLayoutConstraint, it might benefit someone.

identify tabs in QT Qtabwidget

if anyone has a good example of how can I identify that the user have chosen a tab in a window using QT provide it to me. I searched on line and the provided code give me error .. so here what I am trying to do :
I have a main window which has 3 tabs I will mainly show the same video on all of them but in each will run different algorithm, so I don't want them to run all the time because it will consume lots of processing from my cpu, so I would like to only make it work when the user select or open the tab .. here what I tried :
QObject::connect(ui->tabWidget, SIGNAL(ui->tabWidget->currentChanged(int idx)), ui->label, SLOT(setNum(int idx)));
and it gives me this error
Object::connect: No such signal QTabWidget::ui->tabWidget->currentChanged(int idx)
When you write a connect statement, do not include variable names or parameter names in the SIGNAL or SLOT macros. i.e., you should write this:
QObject::connect(ui->tabWidget, SIGNAL(currentChanged(int)), ui->label, SLOT(setNum(int)));

Xcode 4 disable "fix-it" popup

I'm fine with Xcode 4 telling me that I have an error. But that pop-up pretty much always has the wrong solution. Is there any way I can get rid of it permanently?
From what I've seen, it looks like you may need to disable the various types of warnings one by one. A list is found here:
http://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.0.1/gcc/Warning-Options.html#Warning-Options
To change them:
Bring up the project navigator and choose your project. In the main window that appears, choose "All". Under the section "LLVM compiler 2.0 - Warnings", choose "Other Warning Flags". Add the flag "Wno-idiomatic-parentheses" for both "Debug" and "Release." Now clean and recompile ( from if(self = [super init]) - LLVM warning! How are you dealing with it?)
I noted in the apple dev link that the following option should inhibit all warnings:
-w Inhibit all warning messages.

how to connect QActions to SLOTS using qt designer

I have created a nice looking toolbar using qt Designer and populated it with some actions.
I tried to connect the actions to slots visually from qt designer by clicking edit> signals and slots. This DID NOT WORK because i could not find any QAction signals.
Question.
Is there a way to connect the QAction SIGNAL(triggered()) to my slots within QT designer?
Please help.
PS:
I am currently being forced to connect through code:
QObject::connect(myAction, SIGNAL(triggered()),this, SLOT(myActionWasTriggered()))
but ia am lazy and i wish to connect using qt designer.
There's "Signal/Slot Editor" docked panel (Toggled with View->Signal/Slot Editor).
You can connect your actions there.
You may also need to add your custom slots via the "Change signals/slots" form context menu.
To save yourself some work, use the auto-connection feature (see QMetaObject::connectSlotsByName). Basically, all slots named with a specific pattern of on_objectName_signalName will be auto-connected.
Look here in Docs Designer Connection Mode... How to autconnect in the designer
Use the "Action editor" panel. You can find it near "Signals & Slots editor".
If you have menu, Please name your actions object according to menus , Suppose you have:
File Edit View Tools Help
You have 5 menus bar,
So you'll have a set of action_x , x is a number.Please naming your x according to your menu.
more explaintion:
File = 1
Edit = 2
View = 3
Tools = 4
Help = 5
And suppose :
File---> Open ..Close
Edit---> find...replace
View---> ZoomIn ... ZoomOut
Tools--->calender... prefrences
help---> help... about
You have 5x2 = 10 , you have 10 action, please manage such as:
action_11 == File>Open
action_12 == File>close
action_21 == Edit>find
and so on..
Above type of managing make easy your coding .....

Resources