w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Get QWidget absolute position in the MainWindow constructor
I think you can't, not reliably and portably anyway. The position is not decided yet, and decision is often made by window manager, not the application. So, what you should do is override moveEvent(), resizeEvent() and/or showEvent() Those are the right place to do stuff like that, instead of constructor.

Categories : Qt

CSS position between Win / Linux / Mac Logo Position
I can't tell you unless I see the CSS. Post the css on something like pastbin.com or if it isn't real long then add it to your question and then you are likely to get some answers, but I can't tell you what is wrong with your CSS from a picture of the results. Too many possibilities. Now I'm wishing I had asked for a demonstration instead. Am I correct in thinking that the text is part of a horizontal menu and the logo is completely separate and not contained by the text container at all? If this is the case and the image looks and behaves like you want then perhaps it is the menu that needs tweaking to get it to match up correctly. At first I was thinking this was something like a div containing text and an image or having an image as a background. If you could go ahead and post a

Categories : CSS

get a character at a given position in a linux console application
The approach you're trying here is so fragile as to be impossible. GetCharAt() assumes that every character that's output is printable, and that nothing is moving the cursor around. Your SetCursorPosition() does exactly that, so the idea of tracking what has been output so far simply will not work. Plus, other processes may output stuff to the console right in the middle of your program, like a wall message from root. What you want instead is "ncurses", http://en.wikipedia.org/wiki/Ncurses, a library that probably already exists on your system. It has solved these problems already in a terminal-independent way, and provides a large suite of functions for moving around the screen, scrolling, drawing, colors, etc, all in the terminal.

Categories : C++

Global text caret position in Linux
There is no such thing as a caret position in X11. While the older UIM framework did a fairly good job of displaying the input method UI near the cursor position, this failed often enough that it was abandoned. You might want to take a look at the SCIM framework. Note that it is usually preferred to hint the application at the completion state rather than provide a separate editor, as this gives a more seamless integration.

Categories : Python

Create .SO files on Linux without using PIC (position independent code) (x86 32bit)
What happens if I just drop the -fPIC when compiling a .so-file? The resulting shared object ELF file would (very probably) be dynamically loaded at semi-random (i.e. unpredictable) page addresses (e.g. because the mmap syscall will encounter ASLR). And the linker would produce a huge lot of relocation operations. So the dynamic linker (ld.so) would have to slowly process a big lot of relocations, so your text segment would have to be rewritten (and won't be efficiently read-only shared with other processes using the same .so file). So in practice forgetting the -fPIC on a shared object (i.e. dynamically linked library) is most often a bad idea, even if it is possible. Read Drepper's HowTo do Dynamic Shared Libraries paper and Wheeler's Program Library Howto BTW, position independ

Categories : Linux

WM_CREATE and MainWindow
I don't know anything about the Win32Gui library in particular, but I've used plenty of Win32 wrapper libraries and even written one myself. Handling the WM_CREATE message (which is sent to a window after it is created) is the typical way of creating dynamic child windows such as button controls. This would be the same regardless of whether you're working directly with the Win32 API or using a wrapper library. The only difference might be how that wrapper library expects you to handle the message. For example, in MFC, you would override a member function of the window class called OnWmCreate. But you really can create child windows anywhere in the code. You aren't forced to do it in response to WM_CREATE. You could do it in response to WM_KEYDOWN if you wanted. The only requirement is th

Categories : C++

Vertical QToolBar from MainWindow
You're using the wrong enum for setLayoutDirection: // Don't use this. You need to use a different method // if you want it placed against the left side. enum ToolBarArea { LeftToolBarArea = 0x1, RightToolBarArea = 0x2, TopToolBarArea = 0x4, BottomToolBarArea = 0x8, ToolBarArea_Mask = 0xf, AllToolBarAreas = ToolBarArea_Mask, NoToolBarArea = 0 }; You need to use something from Qt::LayoutDirection: enum LayoutDirection { LeftToRight, RightToLeft, LayoutDirectionAuto }; ui->_toolbar->setLayoutDirection(Qt::LeftToRight);

Categories : Qt

How to use MainWindow as ShellViewModel View?
Caliburn.Micro doesn't look for ShellView by default, this is how things work. Let's say you have a bootstrapper defined like this: class MyBootsrtapper : Bootstrapper<MyViewModel> { } Then CM (Caliburn.Micro) will look for a view named MyView. So yes you can use MainWindow instead as long as your view model name is MainWindowViewModel. I have answered the other question you have asked and it seems you don't fully comprehend CM so i really really advise you to Start Here and you can always check the projects Documentation on codeplex because it contains all updated information and documentation. Edit: Caliburn.Micro uses a simple naming convention to locate Views for ViewModels. Essentially, it takes the FullName and removes “Model” from it. So, given MyApp.ViewM

Categories : Wpf

What is that cursor-like thing at the top of a Qt MainWindow?
It is default toolbar (It is created automatically if your mainwidget is QMainWindow and you have ui form with it). To get rid of it, do something like this: look at class diagram, when editing your *.ui file and remove QToolBar, named mainToolBar by default, like here -. or you can use void QMainWindow::removeToolBar ( QToolBar * toolbar ) - docs or you can just hide through css or any means possible ( mainToolBar->hide() ) mainWindow->setStyleSheet( "QMenuBar { border: none } QToolBar { border: none }" ); // or toolBar->setStyleSheet( "border: none" ); menubar->setStyleSheet( "border: none" );

Categories : Qt

How to derive from a Qt MainWindow class?
You can get access to central widget, using QMainWindow::centralWidget() and add widgets or layouts to its layout, knowing its structure. A simple example: QMainWindow::centralWidget()->layout()->addWidget(new QLabel(tr("New label")));

Categories : Qt

Qt connect class to MainWindow
In your code: - connect(j, SIGNAL(testsignal), this, SLOT(printtext(const QByteArray& data))); You're missing the parameters after testsignal, so it should be SIGNAL(testsignal(const QByteArray&)). Also, the parameters can not be named, so remove 'data' in the slot. Note that the connect function returns a type of QMetaObject::Connection, which you can test for. If it returns NULL, the connection was not made. Also, when the code runs over a connect function, a debugger output window will usually tell you if the connection failed.

Categories : C++

Qt change MainWindow geometry
You can use the resize() function. As an example, suppose that you want to apply a 1280x1024 resolution to the main window, as your application starts. You can do something like this: int main( int argc, char **argv ) { QApplication app( argc, argv ); MainWindow w; w.resize(1280, 1024); w.show(); return app.exec(); }

Categories : C++

How to add a scene to a view in mainwindow.cpp?
You want 'setScene' not 'addScene'. Since there can only ever be one scene set to a view at a time, 'set' is the proper word for the function name, implying that it replaces whatever scene was previously there. 'add' would imply that the old scene(s) remain present even while the new scene is added, which isn't the case with QGraphicsView. QGraphicsScene scene; QGraphicsView *view = new QGraphicsView(); view->setScene(&scene); //<--- The function name you want. Ofcourse, your QGraphicsView needs to actually be set to your main window. If you want it to fill the entire main window, use: this->setCentralWidget(view); //Assuming 'this' is the QMainWindow widget. As @Merlin069 advises. If you don't want it to fill the entire window, but want other stuff as well, you should

Categories : C++

Show Mainwindow in the right of the screen (Qt 5.1.0)
QDesktopWidget::availableGeometry is not a static function. You can use QApplication::desktop() function to get a QDesktopWidget object: QRect r = this->frameGeometry(); r.moveRight(QApplication::desktop()->availableGeometry()); You will have to put something else in the moveRight() function. You can't put a QRect there. Maybe what you want to do is: QRect r = QApplication::desktop()->availableGeometry(); r.setLeft(r.center().x()); this->resize(r.width(), r.height()); this->move(r.topLeft()); Or if you don't want to resize your window: QRect r = QApplication::desktop()->availableGeometry(); QRect main_rect = this->geometry(); main_rect.moveTopRight(r.topRight()); this->move(main_rect.topLeft());

Categories : C++

QGraphicsView not displaying in mainWindow
You've created a local QGraphicsView variable there in the handleButton1() function that will be destroyed as soon as the function finishes, in your first example, the view would exist until the end of main() which is the end of the application, i.e it exists until you close the application. Your best bet would be to either use Qt Designer to place the QGraphicsView in the MainWindow or to give MainWindow a private QGraphicsView* member variable If you use a private variable, use Qts built in memory management to set the parent of it to the MainWindow so it's cleaned up when the window is destroyed. class MainWindow : QMainWindow { // etc... private: QGraphicsView *view; } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->

Categories : C++

How to update a control on WPF MainWindow
You can try something like this: if (GetLastInputInfo(ref LastInput)) { IdleTime = System.Environment.TickCount - LastInput.dwTime; string s = IdleTime.ToString(); Dispatcher.BeginInvoke(new Action(() => { label1.Content = s; })); } Read more about Dispatcher.BeginInvoke Method here

Categories : C#

Adding FlowDocument to MainWindow
I used the example on this page. http://msdn.microsoft.com/en-us/library/ms751864(v=vs.85).aspx Xaml code <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="20"></RowDefinition> <RowDefinition Height="100*"></RowDefinition> </Grid.RowDefinitions> <Button Name="PrintSimpleTextButton" Content="Print Button" Width="100" Grid.Row="0" Click="PrintSimpleTextButton_Click"></Button> <FlowDocumentReader Name="flowDocRdr" IsFin

Categories : C#

WPF FramePage to MainWindow Control?
You can get a handle on the main page like this: Dim mainPage As MainWindow = TryCast(Application.Current.MainWindow, MainWindow) If mainPage IsNot Nothing The mainPage.frame1.Visibility = Visibility.Collapsed

Categories : C#

Relations between UserControl and MainWindow
Here is just a quick sample to get you started (and what probably was meant by mr. @Adriano): RootViewModel.cs: public class RootViewModel :INotifyPropertyChanged { #region Implementation of INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged = delegate {}; private void OnPropertyChanged(string propertyName) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } #endregion private double _x; private double _y; public double X { get { return _x; } set { _x = value; OnPropertyChanged("X"); } } public double Y { get { return _y; } set { _y = value; OnPropertyChanged("Y");

Categories : C#

QTableView in MainWindow and tab ordering
If I understand the question correctly, you have two QTableViews inside a single QMainWindow (for instance, using a QGridLayout) and possibly other QWidgets, and you want to navigate the keyboard focus between them, but you can't because the keyboard focus stays on a QTableView (most likely the first one). If this is the case, you should try these options (possibly together): First, reimplements the keyPressEvent of your QTableView like this: void MyTableView::keyPressEvent (QKeyEvent * event) { if(event->key() == Qt::Key_Tab) event->ignore(); else QTableView::keyPressEvent(event); } Secondly, in the constructor of you table view, disabling keyboard focus (so that the focus will cycle through your other widgets only by using Tab) void MyTableView::MyTabl

Categories : C++

(Qt C++) Send int value from dialog to MainWindow?
First of all, there is no need to call exec() twice, just use it once within the if statement. To answer your question, you still have the bSelect dialog object (and I'm assuming BlockSelect is a class you define?), so make an accessor function inside it to retrieve the values you want. if( bSelect.exec() == QDialog::Accepted ) { //Get stuff here? //I want to fill yo with the spinbox value yo = bSelect.stuff(); return; } EDIT: Your BlockSelect class needs to contain an accessor function, this means a function that returns a value. int stuff() { return ui->yolo->value();} What I'm doing here is retrieving the spinbox's value (assuming it is named 'yolo') and returning it as a result of calling the 'stuff' function.

Categories : C++

calling user control to the mainwindow in wpf
There is no need to define a user control for the context menu. Instead, declare it in a common resource dictionary (e.g. in App.xaml). Then you can access the context menu via StaticResource: In App.xaml: <Application.Resources> <ContextMenu x:Key="contextMenu"> ... </ContextMenu> </Application.Resources> In the window: <Button x:Name="conbut" ... ContextMenu="{StaticResource contextMenu}" />

Categories : C#

PyQt -- Create a menuBar outside of MainWindow
QMenuBar actually just a typical widget. You can specify any object as a parent. As for C++ this code works fine: #include "widget.h" #include <QMenuBar> Widget::Widget(QWidget *parent) : QWidget(parent) { QMenuBar *mb = new QMenuBar(this); mb->addAction("Hello"); } Widget::~Widget() { }

Categories : Python

How do I reduce dependencies in my bloated WPF MainWindow?
No one can really help you but yourself, i am saying this because the only way to refactor this anti-pattern which is called Constructor Over-Injection and which - by the way - is a symptom of violation of the (SRP) Single Responsibility Principle, the only way is to find commonalities between those dependencies and group related ones into their own class. For example i can see IDialogViewModel, IDialogViewModel2 which seem pretty related to me. IAnotherViewModel and IYetAnotherViewModel seem like candidates too and so on and so on. Grouping those dependencies into other classes will reduce the number of parameters and will let you move some of those 300+ lines of code to where they really belong which on the long run should also help with the SRP.

Categories : Wpf

pyqt: Don't lose focus on mainwindow
Kind of, but not really. Only one window can claim focus on the desktop/operating system level. You want this to be your application or main PyQT object. Then, what you want to do is define a new window type (QObject) that will be treated like a toolbox/dialog within the parent application. This will set a child-like focus attribute. Your application will retain focus on the desktop level, and now you have another inner-focus attribute for windows spawned from within your app. QtGui QStyleOptionToolBox StackOverflow: pyqt popup window

Categories : Python

Cannot find invalidate method for MainWindow
Is it not InvalidateVisual() in WPF? See http://msdn.microsoft.com/en-us/library/system.windows.uielement.invalidatevisual.aspx

Categories : C#

QT declare Mainwindow out of the main class
You can't (well, you can, but you shouldn't). The MainWindon declaration is right where it should be. The problem is that you attempt to create a GUI object before you create the QApplication. Why not create the QApplication where you create the GUI object, just before it?

Categories : C++

Printing to an element of MainWindow from an outside class
You could make your watcher class a QObject itself, push it into a thread, and make it emit signals when it "notices" changes that you want to log with the log informations as the signal parameters. Then, you could push this object in a QThread as follow : QThread* thread = new QThread(); ui->moveToThread(thread); //Create the needed connections thread->start(); Depending on what you need, you may connect a signal to the thread's start() slot instead of calling it directly. (Read this to know which connections you'll need with your thread so it is started, stopped and cleaned correctly).

Categories : C++

Handle MainWindow events in ViewModel - WPF
Simply use EventToCommand. ViewModel: public ICommand WindowClosing { get { return new RelayCommand<CancelEventArgs>( (args) =>{ }); } } and in XAML: <i:Interaction.Triggers> <i:EventTrigger EventName="Closing"> <command:EventToCommand Command="{Binding WindowClosing}" /> </i:EventTrigger> </i:Interaction.Triggers>

Categories : Wpf

How binding several ViewModels in MainWindow.xaml?
<Window.Resources> <viewModels:MainWindowViewModel x:Key="Windows1ViewModel" /> <viewModels:OtherViewModel x:Key="OtherViewModel" /> </Window.Resources> <Grid DataContext="{StaticResource Windows1ViewModel}"> <TextBox DataContext="{StaticResource OtherViewModel}" "require to bind OtherVeiwModel here"/> </Grid> Alternately your MainViewModel might be keeping a reference to your OtherViewModel , you can bind the TextBox's DataContext to that alternate view model. CS: public class MainViewModel { public OtherViewModel OtherViewModel{get {retrurn new OtherViewModel();}} } XAML : <TextBox DataContext="{Binding OtherViewModel, Mode=OneWay}" "require to bind OtherVeiwModel here"/>

Categories : C#

How to initialize an object with MainWindow in MonoDevelop?
It's because MonoDevelop may have created the MyClass class in another namespace which has the same name as your solution. So either: right-click "MyClass" in your code and search for something like "resolve" (but I've found right-clicking can freeze your IDE :() add a using statement at the top of your file, e.g. if your solution is named "GtkTests": using GtkTests instead of MyClass use <SolutionName>.MyClass: GtkTests.MyClass MyClassInstance1 = new GtkTests.MyClass();

Categories : C#

How to access WPF MainWindow Controls from my own .cs file
You need to create an instance of MainWindow. But there shouldn't be a reason to do that because it will be done automagically in an WPF app. Unless you have specific reason to do that (which I doubt because of this question and because you say you're a novice).

Categories : C#

How to access control of another class in mainwindow WPF using vb
The answer is in the error code you're getting: Unable to cast object of type 'WpfApplication1.MainWindow' to type 'WpfApplication1.Window1'. The object you have is of type 'WpfApplication1.MainWindow'. This means that you can't cast it to 'WpfApplication1.Window1'. Because your root namespace is 'WpfApplication1', the code should read: Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs) Mainwindowtext2.Text = DirectCast(Application.Current.MainWindow, MainWindow).text1.Text End Sub To understand why, the static property Application.Current is holding a reference to the class Application. It's MainWindow property is of type Window. In your application, your main window is type MainWindow, which derives from Window, and can therefore be returned from the Application

Categories : Wpf

Use a control in MainWindow from a nested page WPF VB.NET
Are you getting an instance of the main window or the media element inside of your shared function? If not, this is you problem. You might stick the media element into a shared variable when the main window is loaded or you can access your main window using the rootvisual of your application.current.app.rootvisual. If your issue is something else, please post the code in your shared function that causes the error.

Categories : Wpf

Propagate an event from style to MainWindow in WPF
The practice of using EventSetter in this case, not the best. And here's why: He is bound to the BAML file that and should be event handler Because it, is limited to the global function of the event, he just looking event handler in xaml.cs file. Also, because of this, from MSDN: Event setters cannot be used in a style that is contained in a theme resource dictionary. EventSetter can not be set in the Trigger Quote from link: Because using EventSetter to wire up event handler is a compile-time feature which is plumbed through IStyleConnector interface, there is another interface called IComponentConnector which is used by the XAML compiler to wire up event handler for standalone XAML elements. What alternatives? 1 - Attached dependency property Use the attached depende

Categories : C#

How to close all the windows when Mainwindow closes
Set Application.MainWindow to the instance of your main window and make sure the Application.ShutdownMode is OnMainWindowClose. Also if you do not want the whole application to shut down: Make the MainWindow the Owner of the child windows. (This has other side effects)

Categories : C#

Binding between UserControl and MainWindow issue
Download Link: Here ^^ Link should have a project with everything you were doing working fine. If your looking for suggestions to improve from your code, some pointers: Name your variables with a particular Style Guide. Properties start with "Uppercase". StyleCop can help identifying problems. Yes Style guides are very important :) With MVVM, Your MyThingsCollection should not be a collection of UserControl but they should be a collection of their VM's Don't create VM's in code-behind of the View(Unless your sure about what your doing). Not only will that reset your VM but also do it every so often the View gets created which might not be desirable especially in MVVM. Use a MVVM helper library when starting with MVVM even if you want to do things yourself. Learn the system and then do

Categories : C#

reducing the width of QMenuBar and QToolBar in mainWindow
You can't use that space through layout because this space is already taken by the main menu and the toolbar. There is no option to put something in this space. But you can add a main window's child without putting it in any layout. It will be shown above all layed out children. But you will have to calculate and adjust size and position of this widget manually. For example, add the following code to the main window's constructor: QPushButton* b = new QPushButton("TEST", this); b->move(200, 0); It looks like this:

Categories : Qt

Application MainWindow is null in WPF (using Caliburn Micro)
That's funny, I've just answered this in another post... Try setting the Application.Current.MainWindow property in the Loaded event in the MainWindow.xaml.cs file: private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Application.Current.MainWindow = this; }

Categories : C#

Inheriting a MainWindow class from QMainWindow and Ui_MainWindow
An advantage of the namespace is that it prevents naming clashes. All the automatically generated names from QtDesigner stay in their own namespace. An advantage of making the Ui class a member, instead of using multiple inheritance, is that the Ui class only needs to be forward-declarded in the header. In your code, you have a #include "ui_mainwindow.h", and that in turn drags in a lot of includes from QtWidgets like <QLabel>, <QPushButton> etc. This decreases compilation speed significantly, as everyone who includes mainwindow.h now also includes those QtWidgets includes. When using the Ui class as a member and forward-declaring it, all these includes only need to be compiled when compiling mainwindow.cpp, but not when including mainwindow.h from somewhere else.

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.