Comments (2)
What is the implementation of StaticUpcast<QObject>
for this type? Slots created by #[slot]
attribute will use the object returned from that implementation as the parent object, so if that object is deleted, the connection to your slot will be deregistered. You should make sure that the object returned by StaticUpcast<QObject>
lives long enough.
Another possibility is that your self
object got deleted. Slots created by #[slot]
attribute retain a weak reference to self
, so they won't prevent it from being deleted. Make sure you have strong references to self
. You can write a Drop
implementation for your type to check if it was deleted.
Please don't post code as images. Code in images cannot be copied and is hard to read.
from examples.
@Riateche
Thank you!
I solved!extended the QObject live time.
But must declared a variable in QApplication::init
method. Otherwise it won't work.
Such as
#[derive(Debug)]
struct MainWindow {
transText: Rc<TransText>,
optLine: Rc<OptLine>,
}
pub fn startQt() {
QApplication::init(|_| unsafe {
let mainWindow = QMainWindow::new_0a();
let windowWidget = QWidget::new_1a(&mainWindow);
// I declared a variable in here, but not used
let _mw = initWindowWidgets(&windowWidget);
mainWindow.set_fixed_size_2a(700, 200);
windowWidget.resize_1a(&mainWindow.size());
mainWindow.set_window_title(&qs("Youdao Dict"));
mainWindow.show();
QApplication::exec()
})
}
unsafe fn initWindowWidgets(windowWidget: &QBox<QWidget>) -> Rc<MainWindow> {
let vBox = QVBoxLayout::new_1a(windowWidget);
vBox.set_contents_margins_4a(0, 0, 0, 0);
vBox.set_spacing(2);
vBox.set_direction(Direction::Down);
//初始化输入框
let transText = TransText::new(&vBox);
//初始化操作栏
let _optLine = OptLine::new(&vBox, &transText);
let mw = Rc::new(MainWindow{
transText: transText,
optLine: _optLine
});
mw
}
from examples.
Related Issues (19)
- Build failure on Mac OS X HOT 6
- Items in QTreeWidget don't show if initial Ref gets dropped. HOT 2
- 'GL/gl.h' file not found HOT 4
- Receive QEvent callback HOT 1
- Example of cross platform Qt app (desktop, mobile)
- Much needed example of how to define and use signals and slots using custom Rust types
- Rust + Qt:The trait `cpp_core::cpp_box::CppDeletable` is not implemented for `LoginPage`
- `lights` example fails to link, but `basic_form` works HOT 1
- Looking for SignalOfQlistOfQPointF" and "SlotOfQlistOfQPoint"
- WASM example HOT 2
- custom model question HOT 4
- encouraging... HOT 3
- Method 'start' missing in QTimer HOT 2
- How to use QAbstractListModel? HOT 3
- Current target is unknown HOT 2
- success compiled, but can load the qt library. HOT 9
- Error when compiling on Windows HOT 9
- linking failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from examples.