Iam looking for a good and easy way to propagate a variable, in my case a string from QWizard on to the pages. I have tried to use fields but without registering it this won't work.
So on the third page of my wizard I need a path to a folder where some data can be found, this is used to init a QFileDialog. This QString is not directly coupled to a QWidget. So I can not call registerField on it.
pseudo code:
// setup wizard:
QMyWizard wiz;
QString s = "c:\\";
wiz.SetFolder(s);
I can of course in the Wizard SetFolder function access the page by looking it up and casting but I find this quite ugly. So Is there a good solution to pass on global variable without registering to widgets?
Thanks!
I'll answer my own question.. I did not find handy functionality in the wizard code itself. Now I am using the ability of any derived class from QObject to hold properties in a map from string to QVariant. In the wizard pages you can acces the properties of the parent now.
http://qt-project.org/doc/qt-4.8/qobject.html#setProperty
Related
Hy,
i m working on a qt application styled by a stylesheet, set like
QApplication qApplication(argc, argv);
QFile styleFile("myStyleFile.stylesheet");
bool check = styleFile.open(QFile::ReadOnly);
qApplication.setStyleSheet(styleFile.readAll());
the important window of this application uses a QGraphicsScene (which items are not styleable with stylesheets).
But i wannt a unique look.
So the questions are:
1.) Is there a way to access the set stylesheet properties ( like getProperty("QMenu::item:selected") )?
2.) or does anyone know a css-syntax to xml-file tool? (than one could access the set properties with the qt xml/dom support)
I know that some special properties can be accessed like
QColor mainWindowbackgroundColor =
palette().color( QWidget::backgroundRole() );//Get the backgroundcolor set by stylesheet.
but i am searching for a way to access ALL set properties.
Thank you!
I think you will need to use private Qt classes to do this. This is generally not a good idea as the interfaces are internal and subject to change.
In the Qt (4.8.4) sources \src\gui\text\qcssparser_p.h header the QCss namespace is declared.
Whilst I haven't tried this, it looks like you will need to create a QCss::Parser, call parse to get a QCss::StyleSheet. This object contains the parsed data including a vector of QCss::StyleRule which matches QCss::Selector and QCss::Declaration together, have a look at the comment above the QCss::Declaration to see how it is all broken down.
Final Warning: Using Qt private interfaces is liable to cause maintenance problems - don't do it without a very good reason.
I want to add a help webpage for my Qt Application. The user can use the Qt::WhatsThis "tooltip" to have a explanation about the topic and a URL to a webpage. I edit the WhatsthisTooltips with the Qt Designer and have it language indepentend.
Now I create a "LinkFilter" class for filtering, install it in the viewclass and react on the QEvent::WhatsThisClicked event. This works fine.
Now i would catch every QEvent::WhatsThisClicked in my application, but i looks really messy to install it on really every dialog/view/action/widget. This there some kind of global eventHandler, were I can install my "LinkEvent"class? There must be a nice Qt style way for solving this.
For installing the EventFilter I strongly followed this video-tutorial http://youtu.be/DHgbYxpZkbg
http://qt-project.org/doc/qt-4.8/qapplication.html#notify
Essentially you need to subclass QApplication and override this function. Then you can check if it's the type of event you're looking for and act accordingly.
I want to extend or copy the PopUpManager class to add the ability to keep track of the number of windows.
I just want to add a simple windowCount++ when a window is added and windoCount-- when it's removed.
the problem is PopUpManager is a Singleton class... I wasn't able to make it work properly by extending it. And now I have tried to copy the code from the PopUpManager.as file and just add my variable to the end of its functions. It doesn't seem to be working though since it says my properties are undefined even though they are declared above the constructor.
I am thinking I would have to make a copy of the PopUpManagerImpl.as since that's wehre it seems much of the business resides (PopUpManagerImpl extends EventDispatcher implements IPopUpManager) would that allow me to have access to the variable? and should I ignore the manager and just put it in the implementation class?
here is a link about Using the Flex Singleton register, which helped me out when finding myself in the same situation.
I hope you can inspire from that too.
You likely didn't declare yours properties as static. The PopUpManager uses all static methods - this is why working with it you use syntax like:
PopUpManager.createPopUp(...
instead of
var popUpManager:PopUpManager = new PopUpManager();
popUpManager.createPopUp(...
This means that any variables declared in the PopUpManager need to also be static so as to be accessible at the class level.
public static var windowCount:int
Flex 3 question:
I trying here to avoid having to bind resources to all my components labels ( ie a button) and find a way to have this automated.
Problem:
It corrupts the layout in design mode to bind directly in the mxml label="{resourceManager.getString('myResources', 'submit')}" and makes the design view useless. but when declaring bindings elsewhere, in actionScript or via a bind tag, it is counter productive and prone to many errors and miss.
Proposition:
I would like to create my own button that automatically invoke resources to localize a button label. So the author puts "Submit" in the mxml description of my button, and when running it would take the value of the label ie "submit" and use resourceManager.getString('myResources', 'submit').
but I can't find the way to override the set label function, Is it possible if yes how? else how can I go about it?
Maybe I am missing an essential process here that would make the use of resources more elegant, as well as how to override such thing as a button's label.
Thanks for your advices.
Create a component called MyButton, extending Button. Then use this:
override public function set label(value:String):void {
super.label = resourceManager.getString('myResources', value) || value;
}
Assuming the resource manager returns "null" or "undefined" this will work, and will only replace the value if it exists in "myResources".
If you don't want to override every component you need to do this with, then you can add a FlexEvent.CREATION_COMPLETE event on every component. Then use a single generic function to do your label localization.
I have 2 components for example (editor.mxml using mx:windows), when I click an edit button, I want to get the current value from the other component's datafield? (datagrid.mxml using mx:window)
I do know how to access the main MXML's datagrid by parentDocument or Application.application method, but stumped block if I want to access other way as mentioned above. Keep the code as simple as possible.
You could either do dependency injection, that is, give component A a reference to component B so that they can communicate directly (example of tighter coupling,) or have both components communicate through a common mediator using events (example of more loose coupling.)
Both of those options would be implemented wherever it is that you're creating those components (A and B in this example) and adding them to the display list.
This might be more complicated than it deserves, and it smacks of Pattern-Fever, but you could use a mediator class that listens for the CLICK event from the button and knows enough about the other component to query its property. It could even transmit that data using a custom event, which the button listens for.
While this involves three classes instead of two, it often turns out to be easier to have two components that focus on looking good and one that worries about coordination.
Cheers
Try this:
FlexGlobals.topLevelApplication
This points Your root. From the root You can grab every element You want.
You can also add an id to the custom component like this,
<custom:Editor id="myCustomComponent">
</Editor:AddressForm>
and
access your datagrid's value like this,
var data:ArrayCollection = myCustomComponent.DatagridID.dataProvider;